[英]C# ASP.NET MySql Fatal error encountered during command execution
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand(@"UPDATE `users` SET `firstname`=@firstname,`lastname`=@lastname,`industry`=@industry,`companyname`=@companyname,`country`=@country,`addressone`=@addressone,`addresstwo`=@addresstwo,`city`=@city,`stateOrProvince`=@stateone,`zip`=@zip,`phone`=@phone,`companyphone`=@companyphone,`countrytwo`=@countrytwo,`citytwo`=@citytwo,`statetwo`=@statetwo,`ziptwo`=@ziptwo WHERE `email`=@email", conn);
cmd.Parameters.AddWithValue("@firstname", firstName.Text);
cmd.Parameters.AddWithValue("@lastname", lastName.Text);
cmd.Parameters.AddWithValue("@industry", dropDownIndustry.Text);
cmd.Parameters.AddWithValue("@companyname", companyInfo.Text);
cmd.Parameters.AddWithValue("@country", countryTextbox.Text);
cmd.Parameters.AddWithValue("@addressone", addressInfo.Text);
cmd.Parameters.AddWithValue("@addresstwo", addresstwoInfo.Text);
cmd.Parameters.AddWithValue("@city", cityTextBox.Text);
cmd.Parameters.AddWithValue("@stateone", stateTextBox.Text);
cmd.Parameters.AddWithValue("@zip", zipTextBox.Text);
cmd.Parameters.AddWithValue("@phone", newphone);
cmd.Parameters.AddWithValue("@companyphone", phonecompany);
cmd.Parameters.AddWithValue("@countrytwo", countryTextBoxtwo.Text);
cmd.Parameters.AddWithValue("@citytwo", cityTwoTextBox.Text);
cmd.Parameters.AddWithValue("@statetwo", stateTwoTextBox.Text);
cmd.Parameters.AddWithValue("@email", Session["email"]);
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
serverErrorTextBox.Text = "Data updated Successfully...!" + companyPhoneTextBox.Text + " " + Session["email"] + "";
}
catch(MySqlException ex)
{
serverErrorTextBox.Text = ex.Message;
}
finally
{
conn.Close();
}
我不太清楚这个查询的问题是什么,有人可以帮忙吗,我正在使用它来更新用户信息,这是第一次帮助,所有帮助将不胜感激。
您没有ziptwo参数! 在您的更新语句中
try
{
conn.Open();
MySqlCommand cmd = new MySqlCommand(@"UPDATE `users` SET `firstname`=@firstname,`lastname`=@lastname,`industry`=@industry,`companyname`=@companyname,`country`=@country,`addressone`=@addressone,`addresstwo`=@addresstwo,`city`=@city,`stateOrProvince`=@stateone,`zip`=@zip,`phone`=@phone,`companyphone`=@companyphone,`countrytwo`=@countrytwo,`citytwo`=@citytwo,`statetwo`=@statetwo,`ziptwo`=@ziptwo WHERE `email`=@email", conn);
cmd.Parameters.Add("@firstname",SqlDbType.NVarChar).Value = firstName.Text);
cmd.Parameters.Add("@lastname",SqlDbType.NVarChar).Value = lastName.Text);
cmd.Parameters.Add("@industry",SqlDbType.NVarChar).Value = dropDownIndustry.Text);
cmd.Parameters.Add("@companyname",SqlDbType.NVarChar).Value = companyInfo.Text);
cmd.Parameters.Add("@country",SqlDbType.NVarChar).Value = countryTextbox.Text);
cmd.Parameters.Add("@addressone",SqlDbType.NVarChar).Value = addressInfo.Text);
cmd.Parameters.Add("@addresstwo",SqlDbType.NVarChar).Value = addresstwoInfo.Text);
cmd.Parameters.Add("@city",SqlDbType.NVarChar).Value = cityTextBox.Text);
cmd.Parameters.Add("@stateone",SqlDbType.NVarChar).Value = stateTextBox.Text);
cmd.Parameters.Add("@zip",SqlDbType.NVarChar).Value = zipTextBox.Text);
cmd.Parameters.Add("@phone",SqlDbType.NVarChar).Value = newphone);
cmd.Parameters.Add("@companyphone",SqlDbType.NVarChar).Value = phonecompany);
cmd.Parameters.Add("@countrytwo",SqlDbType.NVarChar).Value = countryTextBoxtwo.Text);
cmd.Parameters.AddWithValue("@citytwo",SqlDbType.NVarChar).Value = cityTwoTextBox.Text);
cmd.Parameters.AddWithValue("@statetwo",SqlDbType.NVarChar).Value = stateTwoTextBox.Text);
cmd.Parameters.AddWithValue("@email",SqlDbType.NVarChar).Value = Session["email"]);
cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
serverErrorTextBox.Text = "Data updated Successfully...!" + companyPhoneTextBox.Text + " " + Session["email"] + "";
}
catch(MySqlException ex)
{
serverErrorTextBox.Text = ex.Message;
}
finally
{
conn.Close();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.