我正在尝试在 Visual Studio 2010 中单击按钮时执行查询。一旦我到达 ExecuteReader 语句,它就会说
“无效的对象名称‘任务’。”
表名是任务,字段名也是任务。SQL 连接运行良好。可能是什么问题呢 ?
string MyConString = "Data Source=.\\SQLExpress;Initial Catalog=filter;Integrated Security=SSPI;";
SqlConnection connection = new SqlConnection(MyConString);
string mycmd;
connection.Open();
SqlCommand cmd;
//mycmd = "select task from task where task='" + textBox3.Text + "'";
mycmd = "SELECT task.id FROM task WHERE task.task='plan1'";
cmd = new SqlCommand(mycmd, connection);
SqlDataReader sdr;
string val = "";
//try
//{
//cmd.ExecuteNonQuery();
sdr = cmd.ExecuteReader();