我想将用户输入作为参数从我的 firebird 数据库中删除某些记录。
所以我有以下代码
private void btnOk_Click(object sender, EventArgs e)
{
string code = txtDeleteField.Text;
string connString = ConfigurationManager.AppSettings["DemoAppConnectionString"];
using (FbConnection conn = new FbConnection(connString))
{
using (FbCommand cmd = new FbCommand())
{
cmd.CommandText = "DELETE * FROM DEMOAPP WHERE CODE= @P1";
cmd.Parameters.AddWithValue("@P1", code);
cmd.Connection = conn;
conn.Open();
cmd.Transaction = conn.BeginTransaction();
int a = cmd.ExecuteNonQuery();
if (a == 0)
{
MessageBox.Show("Error!");
}
else
{
MessageBox.Show("Record deleted, ok!" );
}
}
}
}
此代码产生错误
FirebirdSql.Data.FirebirdClient.dll 中出现“FirebirdSql.Data.FirebirdClient.FbException”类型的未处理异常 附加信息:动态 SQL 错误 SQL 错误代码 = -104 令牌未知 - 第 1 行,第 8 列 *