db2界面调用存储过程_使用IBM DB2 Connect驱动程序在i Series上调用存储过程

本文介绍了在C#应用程序中使用DB2Connection调用ISeries存储过程时遇到的问题,该问题导致程序挂起并抛出SQL0902错误。错误信息提到内存保护错误。尽管OleDBConnection可以正常工作,但DB2Connect出现异常。作者尝试了各种调试手段,包括设置页面跟踪,但未能解决问题。存储过程在ISeries端执行正常,问题可能出在客户端与数据库的交互上。
摘要由CSDN通过智能技术生成

我有一个C#应用程序,我试图调用一个ISeries存储过程(包装一个RPGLE程序)。此RPGLE程序将结果集返回给我的C#应用​​程序。

当我尝试调用存储过程时,它会发生错误并无限期挂起。在调试模式下,我可以看到SQL错误消息,如帖子末尾所示。如果我使用OleDBConnection它可以正常工作,但它不适用于DB2 Connect。

我试图在我的页面上设置跟踪,但它没有帮助,因为页面只是挂起而我无法查看堆栈跟踪。

在ISeries方面,我可以看到程序正确执行(为了测试,我在程序结束时在测试文件中写一条记录。)

之前有其他人遇到过此错误吗?我将不胜感激任何帮助。

谢谢。

码:-

DB2Connection conn1 = new DB2Connection(ConfigurationManager.ConnectionStrings ["db2IBM"].ConnectionString);

conn1.Open();

string callString5 = "PGMLIBLE.GETCONSIGNMENTS";

DB2Command cmd1 = new DB2Command(callString5, conn1);

cmd1.CommandType = CommandType.StoredProcedure;

cmd1.CommandTimeout = 5;

DB2Parameter prmCons = cmd1.Parameters.Add("prmCons", DB2Type.Char, 7);

prmCons.Direction = ParameterDirection.Input;

prmCons.Value = "JUT0016";

DB2Parameter prmCmp = cmd1.Parameters.Add("prmCmp", DB2Type.Char, 3);

prmCmp.Direction = ParameterDirection.Input;

prmCmp.Value = "DTA";

DB2Parameter prmIorE = cmd1.Parameters.Add("prmIorE", DB2Type.Char, 1);

prmIorE.Direction = ParameterDirection.Input;

prmIorE.Value = "Y";

DB2DataAdapter adp = new DB2DataAdapter(cmd1);

DataTable dt = new DataTable();

adp.Fill(dt);

// If I just execute cmd1.executeNonquery it doesn't error.

// cmd1.ExecuteNonQuery();

GridView2.DataSource = dt;

GridView2.DataBind();

conn1.Close();

conn1.Dispose();

cmd1.Dispose();

错误信息:-

ERROR [58005] [IBM][DB2.NET] SQL0902 An unexpected exception has occurred in Process: 5652 Thread 10 AppDomain: Name:aa196883-1-129406018469512609

There are no context policies.

Function: SQLExecDirectADONET (Params)

CallStack: at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)

at System.Environment.get_StackTrace()

at IBM.Data.DB2.DB2ConnPool.HandleUnknownErrors(String strFncMsg, Exception exception, Boolean bThrow)

at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method, DB2CursorType reqCursorType, Boolean abortOnOptValueChg, Boolean skipDeleted, Boolean isResultSet, Int32 maxRows, Boolean skipInitialValidation)

at IBM.Data.DB2.DB2Command.ExecuteReaderObject(CommandBehavior behavior, String method)

at IBM.Data.DB2.DB2Command.ExecuteReader(CommandBehavior behavior)

at IBM.Data.DB2.DB2Command.ExecuteDbDataReader(CommandBehavior behavior)

at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)

at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

at ShowConsignmentsOpen.Page_Load(Object sender, EventArgs e) in c:InetpubTestStoredProcShowConsignmentsOpen.aspx.cs:line 50

at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)

at System.Web.UI.Control.OnLoad(EventArgs e)

at System.Web.UI.Control.LoadRecursive()

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest()

at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)

at System.Web.UI.Page.ProcessRequest(HttpContext context)

at ASP.showconsignmentsopen_aspx.ProcessRequest(HttpContext context) in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Filesteststoredprocf35f719b99c08192App_Web_yti93vc5.2.cs:line 0

at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

at System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)

at System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)

at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)

at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)

at System.Web.HttpRuntime.ProcessRequest(HttpWorkerRequest wr)

at Microsoft.VisualStudio.WebHost.Request.Process()

at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn) InnerException Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Check InnerException property for more detail. SQLSTATE=58005

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值