gpt4 book ai didi

c# - 我无法为 mysql 应用自动增量

转载 作者:行者123 更新时间:2023-11-29 13:01:56 26 4
gpt4 key购买 nike

"INSERT INTO Fn_Registration VALUES ( '"+ 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 + "')";

这是我插入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();

最佳答案

在插入查询中,您可以使用:

INSERT INTO Fn_Registration(Names,of,columns,that,you,want,to,give,a,value) VALUES(values,for,those,columns);

如果您随后从要赋予值的列名中排除 id 列,SQL 应自动递增该值。

关于c# - 我无法为 mysql 应用自动增量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23218905/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com