“命令执行期间遇到致命错误." mysql连接器.net [英] "Fatal error encountered during command execution." mysql-connector .net

查看:71
本文介绍了“命令执行期间遇到致命错误." mysql连接器.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码:

MySqlTransaction trnData = pconDB.BeginTransaction();
MySqlCommand cmdData = new MySqlCommand();

cmdData.Connection = pconDB;
cmdData.CommandTimeout = plngQueryTimeOut;
cmdData.CommandType = CommandType.Text;
cmdData.CommandText = "CALL spsOME( 4, 'DATA', 389552022,@intOutReturn);";
cmdData.Transaction = trnData;
plngRecordsCount = cmdData.ExecuteNonQuery();

CALL语句是否可以直接从.net库中获取?相同的查询正在工作台上工作.

Isn't CALL statement possible directly from .net library? The same query is working on workbench.

推荐答案

将以下两行更改为:

   cmdData.CommandType = CommandType.StoredProcedure;
   cmdData.CommandText = "spsOME( 4, 'DATA', 389552022,@intOutReturn);";

您还需要为@intOutReturn参数将参数添加到cmData的Parameters集合中.我不会举一个例子,因为语法随数据库而异,我也不知道MySQL的样子.

You will also need to add a parameter to the Parameters collection of cmData for the @intOutReturn parameter. I won't give an example of this as the syntax varies with databases and I don't know what MySQL's looks like.

此外,这一行:

cmdData.Transaction = trnData;

..仅在您执行其他应在同一事务中的数据库操作时才是必需的.如果您不愿意,我会把那行留在外面.

..is only necessary if you are doing other db operations which should be in the same transaction. If you're not, I'd leave that line out.

这篇关于“命令执行期间遇到致命错误." mysql连接器.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆