[求助]C#连接数据库超级简单问题
string ConnStr = "SERVER=(local);USER ID=sa;PWD=;DATABASE=abc ";
string strsql = "select * from Member ";
SqlConnection Conn = new SqlConnection(ConnStr);
SqlCommand mycommand = new SqlCommand(strsql, Conn);
Conn.Open();
SqlDataReader mySqlDataReader = mycommand.ExecuteReader();
Conn.Close();
提问
DataTable myTable = new DataTable();
如何把数据集放到myTable里面?
[解决办法]
换成SqlDataAdapter:
DataTable myTable = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter(mycommand,ConnStr);
adapter.Fill(myTable );