【发布时间】:2014-02-08 13:56:22
【问题描述】:
必须声明标量变量“@Id”
SqlConnection con = new SqlConnection(@"connectionstring");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = ("SELECT Goal from Planning WHERE Id = @Id");
int goal = (int)cmd.ExecuteScalar();
有人可以帮助我吗?
【问题讨论】:
-
第一行是你的错误信息吗?
-
是的,这是我的第一条错误消息
-
顺便说一句,您的 连接字符串 似乎也错了。如果你的
connectionstring是一个变量,你应该像new SqlConnection(connectionstring)一样使用它而不是new SqlConnection(@"connectionstring")。
标签: c# sql-server