2 kiss of death kiss_of_death 于 2014.02.07 20:47 提问

错误源:.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");
}

http://img.blog.csdn.net/20140207204330390?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQva2lzc19vZl9kZWF0aA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast

Csdn user default icon
上传中...
上传图片
插入图片