“插入Fn_Registration值(‘+ txtFirstName.Text +’‘、’‘+ txtLastName.Text +’、‘+’‘+ txtEmailId.Text +’、”+ "‘+ txtPassword.Text +’、“+ "‘’+ txtPanNumber.Text +‘、”+ "’+‘+ txtAddress1.Text +“、”+’‘+’+ txtAddress2.Text +“、”+“+‘+ txtFaxNo.Text +’,“+ "‘+ txtFirmName.Text +’‘,’+‘’+ txtPhoneNumber.Text +‘’,‘+’‘+ txtTinNumber.Text +’‘,’‘+ txtAccountsStart.Text +’‘,’‘+ txtAccountsEnd.Text +’‘,’‘+ cbbVat.Text +’,‘+’+ cbbstates.Text +‘’,”+ "‘+’+ txtCity.Text +‘’,‘’+ txtBankName.Text +‘,’‘+ txtAccountNumber.Text +’,“+”+ txtIFSCCode.Text +‘,+’+‘+ txtBN1.Text +’,+‘’+ txtAC2.Text +‘,’+‘+ txtIFSC2.Text +’‘,“+”+txtIFSC2.Text+’‘;
这是我在mysql数据库中插入的代码,其中id num必须是自动递增的,但是mysql不执行自动增量可以帮助任何人.
C#代码
string regInset = "INSERT INTO Fn_Registration VALUES ('" + 101 + "', '"+
txtFirstName.Text + "', '" + txtLastName.Text + "', " + " '" + txtEmailId.Text +
"', " + " '" + txtPassword.Text + "', " + " '" + txtPanNumber.Text + "', " + " '" +
txtAddress1.Text + "', " + " '" + txtAddress2.Text + "', " + " '" + txtFaxNo.Text +
"'," + " '" + txtFirmName.Text + "', " + " '" + txtPhoneNumber.Text + "', " + " '"
+ txtTinNumber.Text + "','" + txtAccountsStart.Text + "','" + txtAccountsEnd.Text +
"','" + cbbVat.Text + "', " + " '" + cbbstates.Text + "', " + " '" + txtCity.Text +
"', '" + txtBankName.Text + "', '" + txtAccountNumber.Text + "', " + " '" +
txtIFSCCode.Text + "', " + " '" + txtBN1.Text + "', " + " '" + txtAC1.Text + "', " +
" '" + txtIFSC1.Text + "', " + " '" + txtBN2.Text + "', " + " '" + txtAC2.Text + "', "
+ " '" + txtIFSC2.Text + "')";
cmd = new MySqlCommand(regInset, con);
da = new MySqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds, "Fn_Registration");
this.clearData();发布于 2014-04-22 12:07:56
在插入查询中,可以使用:
INSERT INTO Fn_Registration(Names,of,columns,that,you,want,to,give,a,value) VALUES(values,for,those,columns);如果从要给值的列的名称中排除id列,则SQL应自动增加值。
发布于 2014-04-22 12:08:03
https://stackoverflow.com/questions/23218905
复制相似问题