我用asp.net c#做过网站,现在用c#.net做东西,发现连基本的连接数据库都不对(不能执行但没错)
代码如下:
 string constr="******";
 string str;
 str="select count(*) from Admin ";
 
System.Data.SqlClient.SqlConnection sqlcn = new System.Data.SqlClient.SqlConnection();
sqlcn.ConnectionString=constr;
System.Data.SqlClient.SqlCommand scalar=new System.Data.SqlClient.SqlCommand(str,sqlcn);scalar.Connection.Open();

int getno=(int)scalar.ExecuteScalar();
scalar.Connection.Close();
此程序在asp.net中执行没有问题,但是c#.net不能运行,各位高手请指教