错误源:.Net SqlClient Data Provider 错误信息:对象名“***”无效 请问怎么解决呢
应该是已经连接了数据库,但是出现表的无效,初学,望高手予以解答
SqlConnection conn = new SqlConnection(@"server = .\sqlexpress;
integrated security = true; database = AdventureWorks");
string sql = @"select count(*) from Production.Product";
SqlCommand cmd = new SqlCommand(sql, conn);
txtScalar.AppendText("Command created and connected.\n");
try
{
conn.Open();
txtScalar.AppendText("Number of Product is :");
txtScalar.AppendText(cmd.ExecuteScalar().ToString());
txtScalar.AppendText("\n");
}
catch (SqlException ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
conn.Close();
txtScalar.AppendText("Connection Closed");
}
问题:写了一整行的数据,但是没有点击回车键确认,直接用鼠标跳出此行编辑的话会不断报错:"未更新任何行...",且出现很多红色感叹号。解决方法:每当输入完一行的数据后按下回车键来退出编辑准备进入一下行编辑即可。