mysql 执行两条insert 失败,使用mysql INSERT执行命令时遇到致命错误

I am trying to execute a INSERT statement on a mySQL DB in C#:

string value1 = "INSERT INTO new_t(id, bid, idate,ino,int,icy) " +

"VALUES ('" + id + "', '" + bid + "', '" + idate + "', '" + ino + "', '" + int + "', 'ee')";

string result = true;

try

{

if (dbConnection.State == System.Data.ConnectionState.Open)

{

MySqlCommand myCmd = new MySqlCommand(value1, dbConnection);

if (myCmd.ExecuteNonQuery() == 0)

result = false;

}

}

catch (NotImplementedException ex)

{

MsgBox("1 " + ex.Message + DateTime.Now);

throw new NotImplementedException();

}

catch (Exception ex)

{

MsgBox("2 " + ex.Message + DateTime.Now);

throw new Exception();

}

return result;

}

This fails with the error: mysql Fatal error encountered during command execution. Any ideas on why this would fail?

What I have tried:

i have try in local DB, but can't get this error. this error only appear in when connect to other PC DB via IP.

解决方案

No help can be provided because we need to know the types and values of id, bid, idate, ino and int.

You also need to show the contain of value1 because your method to pass parameters is subject to a problem called code injection.

SQL Injection[^]

SQL injection - Wikipedia, the free encyclopedia[^]

Nota: it is a bad idea to use a variable type as a variable name.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值