超极郁闷的SqlCommand语句...
SqlCommand Sc = new SqlCommand();
SqlDataReader query;
string mysql1 = "select max(userid) as val from smt_companyuser ";
Sc.CommandText = mysql1;
query = Sc.ExecuteReader();
query.Read();
当程序执行到query = Sc.ExecuteReader(); 就不执行下面任何语句了,,,也不报任何错误....
各位大哥指教指教
------解决方案--------------------刚发错了,应该是
SqlConnection conn=new SqlConnection( "server=.;database=;uid=sa;pwd= ");
SqlCommand Sc = new SqlCommand(conn);
------解决方案--------------------TO:SqlConnection conn=new SqlConnection( "server=.;database=;uid=sa;pwd= ");
你的数据库名称是故意没写,还是忘了写了??
------解决方案--------------------if(ConnectMain.State != ConnectionState.Closed)
{
ConnectMain.Close();
}
ConnectMain.Open() ;
打开连接前执行以上代码看看