C#读出数据 (datareader)
首先我定义了类:classdatabase{publicstaticstringpower;}然后stringconnString="server=XP-20110218...
首先我定义了类: class database
{
public static string power;
}
然后
string connString = "server=XP-201102181145\\SQLEXPRESS;database=StudentManagement;uid=sa;pwd=123;";
SqlConnection connecion = new SqlConnection(connString);
connecion.Open();
string sqlQuery = "SELECT *FROM AdminInfo WHERE adminName='" + denglum + "'";
SqlCommand mycmd = new SqlCommand(sqlQuery, connecion);
SqlDataReader dr = mycmd.ExecuteReader();
问题是 我用
database.power = dr["Power"].ToString();
却不能把表中的Power值赋给 类中的power静态变量 展开
{
public static string power;
}
然后
string connString = "server=XP-201102181145\\SQLEXPRESS;database=StudentManagement;uid=sa;pwd=123;";
SqlConnection connecion = new SqlConnection(connString);
connecion.Open();
string sqlQuery = "SELECT *FROM AdminInfo WHERE adminName='" + denglum + "'";
SqlCommand mycmd = new SqlCommand(sqlQuery, connecion);
SqlDataReader dr = mycmd.ExecuteReader();
问题是 我用
database.power = dr["Power"].ToString();
却不能把表中的Power值赋给 类中的power静态变量 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询