我向数据库中添加一行数据用了下面的代码,怎么没添加成功了。请问是什么原因?是我的代码问题还是什么问题?
帮忙各位师兄、姐解决一下
SqlConnection conn = new SqlConnection(
"server=localhost;database=Student;integrated security=SSPI");
SqlCommand mySqlCommand = conn.CreateCommand();
mySqlCommand.CommandText = "select * from 用户表";
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter();
mySqlDataAdapter.SelectCommand = mySqlCommand;
DataSet myDataSet = new DataSet();
conn.Open();
int i = mySqlDataAdapter.Fill(myDataSet, "用户表");
conn.Close();
DataTable myDataTable=myDataSet.Tables["用户表"];
DataRow myDataRow = myDataTable.NewRow();
myDataRow["用户名"]="mrs";
myDataRow["密码"]="123";
myDataTable.Rows.Add(myDataRow);
conn.Open();
int j = mySqlDataAdapter.Update(myDataTable);
conn.Close();
[求助]添加数据