SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sql2005"].ConnectionString); SqlDataAdapter adp = new SqlDataAdapter(); adp.SelectCommand.Connection = con; adp.SelectCommand.CommandType = CommandType.Text; adp.SelectCommand.CommandText = "SELECT id,name,pwd,class,age FROM member"; 提示con对象为空
1 回答
Smart猫小萌
TA贡献1911条经验 获得超7个赞
改成这样试试
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sql2005"].ConnectionString);
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "SELECT id,name,pwd,class,age FROM member";
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
con.Open();
adp.Fill(ds);
con.Close();
- 1 回答
- 0 关注
- 458 浏览
添加回答
举报
0/150
提交
取消