“在命令执行期间遇到致命错误”
总详情:
mysql.data.MysqLClIEnt.MysqLException: Fatal error encountered during command execution. ---> mysql.data.MysqLClIEnt.MysqLException: Fatal error encountered attempting to read the resultset. ---> mysql.data.MysqLClIEnt.MysqLException: Reading from the stream has Failed.---> System.IO.EndOfStreamException: Attempted to read past the end of the stream. at mysql.data.MysqLClIEnt.MysqLStream.ReadFully(Stream stream,Byte[] buffer,Int32 offset,Int32 count) at mysql.data.MysqLClIEnt.MysqLStream.LoadPacket()--- End of inner exception stack trace --- at mysql.data.MysqLClIEnt.MysqLStream.LoadPacket() at mysql.data.MysqLClIEnt.MysqLStream.ReadPacket() at mysql.data.MysqLClIEnt.NativeDriver.GetResult(Int32& affectedRow,Int32& insertedID) at mysql.data.MysqLClIEnt.Driver.GetResult(Int32 statementID,Int32& affectedRows,Int32& insertedID) at mysql.data.MysqLClIEnt.Driver.NextResult(Int32 statementID) at mysql.data.MysqLClIEnt.MysqLDataReader.NextResult()--- End of inner exception stack trace --- at mysql.data.MysqLClIEnt.MysqLDataReader.NextResult() at mysql.data.MysqLClIEnt.MysqLCommand.ExecuteReader(CommandBehavior behavior) --- End of inner exception stack trace --- at mysql.data.MysqLClIEnt.MysqLCommand.EndExecuteNonquery(IAsyncResult asyncResult
)
我的c#代码:
internal voID InsertUpdateMysqL(string connectionstring,string storedprocedure) { string sLog = "internal voID InsertUpdateMysqL(string connectionstring,string storedprocedure)"; MysqLConnection conn = new MysqLConnection(); int rowsAffected = 0; try { if (!string.IsNullOrEmpty(storedprocedure) && !string.IsNullOrEmpty(connectionstring)) { conn.ConnectionString = connectionstring; MysqLCommand cmd = new MysqLCommand(storedprocedure); cmd.Connection = conn; conn.open(); IAsyncResult myResult = cmd.BeginExecuteNonquery(null,null); SetProgressinRichText("In progress\n"); while (!myResult.IsCompleted) { SetProgressinRichText("."); } rowsAffected = cmd.EndExecuteNonquery(myResult); } } catch (MysqLException ex) { this.service.WritetoLog(source,sLog + "\n" + ex.Message + "\n" + ex.StackTrace); } catch (Exception ex) { this.service.WritetoLog(source,sLog + "\n" + ex.Message + "\n" + ex.StackTrace); } finally { if (conn.State != System.Data.ConnectionState.Closed) conn.Close(); } }
sp是这样的:
DEliMITER $$CREATE PROCEDURE `SPInsertUpdateCity`( in SP_Cityname VARCHAR(100) charset utf8,in SP_CitySynonyms varchar(100) charset utf8,in SP_CityNumberPostOffice varchar(100)) BEGIN if(not exists(select CityID from city where Cityname = SP_Cityname)) then insert into city(Cityname,CityNumberPostOffice) values(SP_Cityname,SP_CityNumberPostOffice); insert into citysynonym (CityID,CitySynonymname) values(Last_insert_ID(),SP_CitySynonyms); else if(not exists( select CitySynonymID from citysynonym where CitySynonymname = SP_CitySynonyms)) then insert into citysynonym (CityID,CitySynonymname) values((select cityID from city where Cityname=SP_Cityname),SP_CitySynonyms); end if; end if; END$$DEliMITER ;
连接字符串:
Server=XXXX; Port=XXXX; Database=XXXX; UID=XXXX;Pwd=XXXX;charset=utf8;default command timeout=7200;
但是当我在本地MysqL上表示优异时,它也是成功的!
对于远程MysqL我试图发送少量数据(3条记录)并且执行成功,但对于大数据(1500条记录),执行失败
以上是内存溢出为你收集整理的c# – 命令执行期间遇到致命错误全部内容,希望文章能够帮你解决c# – 命令执行期间遇到致命错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)