解决方案 »
- 下载象flashget引用页问题
- c#调用DLL报错:attempted to read or write protected memory。急!急!急!
- VS2003内,winform下的DATAGRID里面的dataGridTextBoxColumn的LEAVE事件,获取不到文本值!!!?
- 各位仁兄仁姐,我自建了一个网站,但不满意网站名称,希望大家出点主意
- 在winform中如何实现文字平滑上滚
- C#学习迷茫中,望高手指点!下一步路应该如何走,没分了,今天的最后20加上了,等明天加了分,再加上
- 如何把sniffer过来的,字节数组byte[],还原出来,其中有中文,又有英文,请大家帮忙解决一下.
- c#问题,请进入指教
- dataTable.Select()怎么用?
- 怎么实现动态数组呢?不能用hashtable,怎么实现呢?急!!!
- 在线急等啊DataSet 变量的问题
- 一个集合接口的问题
ADO.NET的流程会不 SqlConnect SqlCommand open 执行 close,这样数据才会被擦入到数据库里面啊插入完成后在读取到DataTable里面绑定即可显示你刚才加的数据了。
{
string strUserID = this.dataGridView_user.SelectedCells[0].Value.ToString();
MessageBox.Show(strUserID); this.dataGridView_user.SelectedCells[0].Value = textBox1_UserID.Text;
this.dataGridView_user.SelectedCells[2].Value = textBox3_PWD.Text;
this.dataGridView_user.SelectedCells[4].Value = textBox2_re.Text; this.dataGridView_user.SelectedCells[3].Value = comboBox1_Group.Text; sqlDA.Update(ds, "T_User");
}
必须选择插入后不再有改动的列作为主键,如果没有这个列,就必须使用自增长列DataSet ds = new DataSet();
SqlDataAdapter sda;SqlCommandBuilder scb = new SqlCommandBuilder(sda);
sda.Update(ds);
this.dataGridView1.DataSource = ds.Tables[0];
你的主键是int行的话,就设置自增长
Guid的话。Guid.NewGuid()总之就是增加时不要人工输入主键
必须使用自增长列DataSet ds = new DataSet();
???
我添加一个用户数据进去,怎么要增加列了??
string strUserID = textBox1_UserID.Text;
string strUserPWD = textBox3_PWD.Text;
string strGroupID = comboBox1_Group.Text;
string strRe = textBox2_re.Text; //string[] strRow ={ strUserID, "", strUserPWD, strGroupID, strRe };
//dataGridView_user.Rows.Add(new object[] { strUserID, "22", strUserPWD, strGroupID, strRe }); DataRow dRow = dt.NewRow();
dRow["UserID"] = strUserID;
dRow["UserName"] =strUserID;
dRow["UserPWD"] = strUserPWD;
dRow["GroupID"] = strGroupID;
dRow["Re"] = strRe;
dt.Rows.Add(dRow);
sqlDA.Update(ds, "T_User");如上,添加的时候怎么判断主键已经存在了。