对于学校我需要使用c#和mysql创建一个Web应用程序。 在应用程序中有一个注册页面,但是当我单击按钮完成时,我得到一个语法错误,指出execute.nonquery是错误的。 有人能帮助我吗?
这是代码:
MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["gpopdrachtConnectionString"].ConnectionString);
string insertQ;
insertQ = "Insert into tblWerknemer(Gebruikersnaam, Vnaam, Fnaam, Wachtwoord, Geboortedatum, Geboorteplaats, E-mailadres, Geslacht, Loon, gsmNummer, Nationaliteit, Gemeente, Postcode, StraatEnNr)";
insertQ += "values(@gbr, @Vn, @Fn, @Ww, @GebD, @GebPl, @Email, @Geslacht, @Loon, @gsm, @Nat, @Gemeent, @Post, @Strtnr)";
insertQ += "Insert into tbldiploma(school,NaamDiploma) Values(@school,@diploma)";
insertQ += "Insert into tblpostcode(postcode,gemeente) Values(@Post,@Gemeent)";
insertQ += "Insert into tblstatuut(omschrijving) Values(@omschrijving)";
MySqlCommand cmd = new MySqlCommand();
//= new MySqlCommand(insertQ, conn);
cmd.CommandText = insertQ;
cmd.Connection = conn;
cmd.Parameters.AddWithValue("@gbr", txtgbr.Text);
cmd.Parameters.AddWithValue("@Vn", txtVnaam.Text);
cmd.Parameters.AddWithValue("@Fn", txtfnaam.Text);
cmd.Parameters.AddWithValue("@Ww", txtww.Text);
cmd.Parameters.AddWithValue("@GebD", txtgdatum.Text);
cmd.Parameters.AddWithValue("@GebPl", txtgplaats.Text);
cmd.Parameters.AddWithValue("@Email", txtemail.Text);
cmd.Parameters.AddWithValue("@Geslacht", checkgeslacht.SelectedItem.ToString());
cmd.Parameters.AddWithValue("@diploma", txtdiploma.Text);
cmd.Parameters.AddWithValue("@school", txtschool.Text);
cmd.Parameters.AddWithValue("@Loon", txtloon.Text);
cmd.Parameters.AddWithValue("@omschrijving", txtstatuut.Text);
cmd.Parameters.AddWithValue("@gsm", txtgsm.Text);
cmd.Parameters.AddWithValue("@Nat", txtnat.Text);
cmd.Parameters.AddWithValue("@Gemeent", txtgemeent.Text);
cmd.Parameters.AddWithValue("@Post", txtpost.Text);
cmd.Parameters.AddWithValue("@Strtnr", txtstrt.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
这是错误:
MySql.Data.MySqlClient.MySqlException:'您的SQL语法中有错误;检查与您的MySQL服务器版本对应的手册,以便在'-mailadres,Geslacht,Loon,gsmNummer,Nationaliteit,Gemeente,Postcode,Straat'附近的第1行使用正确的语法