技术开发 频道

解决Remoting无法传输存储过程参数的问题

IT168 技术文档】

    在项目的开发中使用Remoting,并且所有的数据请求服务都是通过Remoting完成的,所以自然就在其中到了传递参数的存储过程,在业务逻辑中把参数构建好后传递到Remoting服务端,在取出存储过程的参数时报错,具体错误不记得了,自己尝试了各种方法也不行,上网资讯也没有结果,最后变通了一下,问题解决了,例子如下:

    以下部分为客户调用端

//先声明参数 private const string PARAM_GUID = "@GUID"; private const string PARAM_VGA_TREEGUID = "@VGATreeGUID"; private const string PARAM_MB_TREEGUID = "@MBTreeGUID"; public static string GetProductTypeByGUID(string GUID, String VGATreeID, String MbTreeID) { try { int lcID = Thread.CurrentThread.CurrentUICulture.LCID; BaseModel bt = new BaseModel(); //构建一个哈希表,把参数依次压入 Hashtable parames = new Hashtable(); parames.Add(PARAM_PROGUID, GUID); parames.Add(PARAM_VGA_TREEGUID, VGATreeID); parames.Add(PARAM_MB_TREEGUID, MbTreeID); //把存储过程名称和带参数的哈希表传入 DataAccess.DataBase.RunProcedureDataSet(lcID, "GetProductTypeByTreeID", parames, ref bt); return bt.Rows[0]["ProductType"].ToString(); } catch (Exception ex) { CommFunction.WriteErrorLogFile("public static string GetProductTypeByGUID(stirng GUID, String VGATreeID, String MbTreeID)出错:" + ex.Message); return "Other"; } }

    以下为服务端:

public void Query(int lcid, string SQLString, Hashtable cmdHashtable, ref BaseModel baseModel)public void Query(int lcid, string SQLString, Hashtable cmdHashtable, ref BaseModel baseModel)
0
相关文章