问题描述
- 错误源:.Net SqlClient Data Provider 错误信息:对象名“***”无效 请问怎么解决呢
-
错误源:.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");
}
时间: 2024-09-17 04:13:47