因此,当我单击网页上的按钮时,如果我在本地执行它,它就可以正常工作。如果我在我的 GoDaddy 网络服务器上执行此操作,它会给我一个“操作必须是可更新查询”错误,并指向我的代码中的 com.ExecuteNonQuery。这是错误的 C#:
protected void submitForMail(object sender, EventArgs e)
{
string constr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\TravelJoansDB.mdb;";
string cmdstr = "INSERT INTO EmailList(FirstName,LastName,EmailAddress) VALUES (@FirstName, @LastName, @EmailAddress)";
OleDbConnection con = new OleDbConnection(constr);
OleDbCommand com = new OleDbCommand(cmdstr, con);
TextBox tFirstName = (TextBox)FormView1.FindControl("FirstName");
TextBox tLastName = (TextBox)FormView1.FindControl("LastName");
TextBox tEmail = (TextBox)FormView1.FindControl("EmailAddress");
con.Open();
com.Parameters.AddWithValue("@FirstName", tFirstName.Text);
com.Parameters.AddWithValue("@LastName", tLastName.Text);
com.Parameters.AddWithValue("@EmailAddress", tEmail.Text);
com.ExecuteNonQuery();
con.Close();
string EmailAdded = "Your E-mail address has been added.";
System.Console.Write(EmailAdded);
}
我不想更新表中的任何记录,我想将它们插入到表中。那么为什么它告诉我操作需要是一个可更新的查询呢?