c#中SqlCommandBuilder更新数据库的问题 10
下面的程序有哪里错了吗?我的userlogin表里设了username是主键,我运行的时候它不显示任何错误,但是数据库里面的数据没有更新,为什么呢?要怎么改啊??谢谢了S...
下面的程序有哪里错了吗?我的userlogin表里设了username是主键,我运行的时候它不显示任何错误,但是数据库里面的数据没有更新,为什么呢?要怎么改啊??谢谢了
SqlConnection conn = new SqlConnection("server=(local);uid=sa;pwd=123456;database=auction");
string str = "select * from userlogin where username='"+Session["username"]+"'";
SqlDataAdapter adapter = new SqlDataAdapter(str,conn);
SqlCommandBuilder cb = new SqlCommandBuilder(adapter);
DataTable table = new DataTable();
adapter.Fill(table);
DataRow newrow =table.Rows[0];
newrow["username"] = TextBox1.Text.Trim();
newrow["userpwd"] = TextBox2.Text.Trim();
newrow["sex"] = RadioButtonList1.SelectedItem.Text.Trim();
newrow["address"] = TextBox3.Text.Trim();
adapter.Update(table); 展开
SqlConnection conn = new SqlConnection("server=(local);uid=sa;pwd=123456;database=auction");
string str = "select * from userlogin where username='"+Session["username"]+"'";
SqlDataAdapter adapter = new SqlDataAdapter(str,conn);
SqlCommandBuilder cb = new SqlCommandBuilder(adapter);
DataTable table = new DataTable();
adapter.Fill(table);
DataRow newrow =table.Rows[0];
newrow["username"] = TextBox1.Text.Trim();
newrow["userpwd"] = TextBox2.Text.Trim();
newrow["sex"] = RadioButtonList1.SelectedItem.Text.Trim();
newrow["address"] = TextBox3.Text.Trim();
adapter.Update(table); 展开
展开全部
DataTable table = new DataTable();
adapter.Fill(table);
DataRow newrow =table.Rows[0];
newrow["username"] = TextBox1.Text.Trim();
newrow["userpwd"] = TextBox2.Text.Trim();
newrow["sex"] = RadioButtonList1.SelectedItem.Text.Trim();
newrow["address"] = TextBox3.Text.Trim();
改
DataSet myds= new DataSet ();
adapter.Fill(myds);
DataRow newrow =myds.Tables[0].NewRow();
newrow["username"] = TextBox1.Text.Trim();
newrow["userpwd"] = TextBox2.Text.Trim();
newrow["sex"] = RadioButtonList1.SelectedItem.Text.Trim();
newrow["address"] = TextBox3.Text.Trim();
myds.Tables[0].Rows.Add(newrow);
adapter.Update(myds);
adapter.Fill(table);
DataRow newrow =table.Rows[0];
newrow["username"] = TextBox1.Text.Trim();
newrow["userpwd"] = TextBox2.Text.Trim();
newrow["sex"] = RadioButtonList1.SelectedItem.Text.Trim();
newrow["address"] = TextBox3.Text.Trim();
改
DataSet myds= new DataSet ();
adapter.Fill(myds);
DataRow newrow =myds.Tables[0].NewRow();
newrow["username"] = TextBox1.Text.Trim();
newrow["userpwd"] = TextBox2.Text.Trim();
newrow["sex"] = RadioButtonList1.SelectedItem.Text.Trim();
newrow["address"] = TextBox3.Text.Trim();
myds.Tables[0].Rows.Add(newrow);
adapter.Update(myds);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询