我不断收到此错误。我读到 OleDb 不支持命名参数,所以我将它们更改为(?, ?)
.
但是不断收到同样的错误
System.Data.OleDb.OleDbException:INSERT INTO 语句中的语法错误。在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) 在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) 在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) 在 System.Data。 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior 行为,字符串方法)在 System.Data.OleDb.OleDbCommand.ExecuteNonQuery() 的 OleDb.OleDbCommand.ExecuteCommand(CommandBehavior 行为,Object& executeResult) 在 Registration.ImageButton1_Click(对象发送者,ImageClickEventArgs e) 在 c:\Users\Nirre\Desktop\Cti Project\Book Club TRY 2\Registration.aspx.cs:line 51
这是 .cs 类中的代码
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (IsPostBack)
{
OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
string insCmd = @"INSERT COUNT(*) INTO Registration(UserName, [Password], EmailAddress, FullName, Country, PasswordRecovery)
VALUES (?, ?, ?, ?, ?, ?)";
OleDbCommand insertUser = new OleDbCommand(insCmd, conn);
insertUser.Parameters.AddWithValue("@UserName", txtUserName.Text);
insertUser.Parameters.AddWithValue("@Password", txtPassoword.Text);
insertUser.Parameters.AddWithValue("@EmailAddress", txtEmail.Text);
insertUser.Parameters.AddWithValue("@FullName", txtFullName);
insertUser.Parameters.AddWithValue("@Country", DdlCountry.SelectedItem.ToString());
insertUser.Parameters.AddWithValue("@PasswordRecovery", txtAnswer.Text);
try
{
insertUser.ExecuteNonQuery();
conn.Close();
Response.Redirect("Login.aspx");
}
catch (Exception er)
{
Response.Write(er);
lblError.Visible = true;
lblError.Text = "An error has ocured pleas try again...!";
}
finally
{
// Code
}
}
}