Remoting is used in the development of the project, and all data request services are completed through Remoting, so naturally there is a stored procedure for passing parameters. After the parameters are constructed in the business logic, they are passed to the Remoting server and then taken out. An error occurred when setting the parameters of the stored procedure. I don’t remember the specific error. I tried various methods but it didn’t work. I also searched online and found no results. Finally, I worked around it and the problem was solved. The example is as follows:
The following part is the client caller.
1//Declare parameters first
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 //Construct a hash table and push the parameters in sequence
15 Hashtable parameters = new Hashtable();
16 parames.Add(PARAM_PROGUID, GUID);
17 parames.Add(PARAM_VGA_TREEGUID, VGATreeID);
18 parames.Add(PARAM_MB_TREEGUID, MbTreeID);
19
20 //Pass in the stored procedure name and hash table with parameters
21 DataAccess.DataBase.RunProcedureDataSet(lcID, "GetProductTypeByTreeID", parames, ref bt);
twenty two
23 return bt.Rows[0]["ProductType"].ToString();
twenty four }
25 catch (Exception ex)
26 {
27 CommFunction.WriteErrorLogFile("public static string GetProductTypeByGUID(stirng GUID, String VGATreeID, String MbTreeID) error: " + ex.Message);
28 return "Other";
29 }
30}
31
32
The following is the server side:
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 //The following constructs the stored procedure parameters
12 SqlParameter[] cmdParms = new SqlParameter[i];
13 int j = 0;
14 foreach (DictionaryEntry 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}
twenty one // ----------------------------------------------- ------------------------------------------
22 #endregion
http://www.cnblogs.com/blockhead/archive/2006/08/17/479720.html