在項目的開發中使用Remoting,並且所有的數據請求服務都是通過Remoting完成的,所以自然就在其中到了傳遞參數的存儲過程,在業務邏輯中把參數構建好後傳遞到Remoting服務端,在取出存儲過程的參數時報錯,具體錯誤不記得了,自己嘗試了各種方法也不行,上網資訊也沒有結果,最後變通了一下,問題解決了,例子如下:
以下部分為客戶調用端
1//先聲明參數
2 private const string PARAM_GUID = "@GUID";
3 private const string PARAM_VGA_TREEGUID = "@VGATreeGUID";
4 private const string PARAM_MB_TREEGUID = "@MBTreeGUID";
5
6 public static string GetProductTypeByGUID(string GUID, String VGATreeID, String MbTreeID)
7 {
8 try
9 {
10 int lcID = Thread.CurrentThread.CurrentUICulture.LCID;
11
12 BaseModel bt = new BaseModel();
13
14 //構建一個哈希表,把參數依次壓入
15 Hashtable parames = new Hashtable();
16 parames.Add(PARAM_PROGUID, GUID);
17 parames.Add(PARAM_VGA_TREEGUID, VGATreeID);
18 parames.Add(PARAM_MB_TREEGUID, MbTreeID);
19
20 //把存儲過程名稱和帶參數的哈希表傳入
21 DataAccess.DataBase.RunProcedureDataSet(lcID, "GetProductTypeByTreeID", parames, ref bt);
22
23 return bt.Rows[0]["ProductType"].ToString();
24 }
25 catch (Exception ex)
26 {
27 CommFunction.WriteErrorLogFile("public static string GetProductTypeByGUID(stirng GUID, String VGATreeID, String MbTreeID)出錯:" + ex.Message);
28 return "Other";
29 &
nbsp; }
30 }
31
32
以下為服務端:
1public void Query(int lcid, string SQLString, Hashtable cmdHashtable, ref BaseModel baseModel)#region public void Query(int lcid, string SQLString, Hashtable cmdHashtable, ref BaseModel baseModel)
2 // -----------------------------------------------------------------------------------------
3 public void Query(int lcid, string SQLString, Hashtable cmdHashtable, ref BaseModel baseModel)
4 {
5 if (!CheckRemotingClIEnt())
6 {
7 return;
8 }
9 Console.WriteLine(DateTime.Now.ToString() + "調用了Query(" + lcid.ToString() + ", string SQLString, Hashtable cmdHashtable, ref BaseModel baseModel)");
10 int i = cmdHashtable.Count;
11 //以下構造存儲過程參數
12 SqlParameter[] cmdParms = new SqlParameter[i];
13 int j = 0;
14 foreach (DictionaryEntry de in cmdHashtable)
15 {
16 cmdParms[j] = new SqlParameter(de.Key.ToString(), de.Value);
17 j++;
18 }
19 Colorful.DBUtility.DbHelperSQL.Query(lcid, SQLString, cmdParms, ref baseModel);
20 }
21 // -----------------------------------------------------------------------------------------
22 #endregion
http://www.cnblogs.com/blockhead/archive/2006/08/17/479720.Html