Stored Procedures | solving | problems
The use of remoting in the development of the project, and all the data request services are completed through the remoting, so naturally in it to pass the parameters of the stored procedures, in the business logic of the parameters are built after the delivery to the remoting server, the parameters in the removal of stored procedures in the wrong times, Specific mistakes do not remember, they tried a variety of methods are not good, the Internet information also has no results, finally modified, the problem solved, examples are as follows:
The following sections are the client call side
1//first declare the parameter
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 {
an int lcID = Thread.CurrentThread.CurrentUICulture.LCID;
11
Basemodel BT = new Basemodel ();
13
14//Build a hash table, and then press the parameters in turn
Hashtable parames = new Hashtable ();
Parames. ADD (Param_proguid, GUID);
Parames. ADD (Param_vga_treeguid, Vgatreeid);
Parames. ADD (Param_mb_treeguid, Mbtreeid);
19
20//The stored procedure name and the hash table with parameters are passed in
DataAccess.DataBase.RunProcedureDataSet (LcID, "Getproducttypebytreeid", Parames, ref BT);
22
Return to BT. rows[0]["ProductType"]. ToString ();
24}
catch (Exception ex)
26 {
Commfunction.writeerrorlogfile ("public static string Getproducttypebyguid (Stirng GUID, String Vgatreeid, String Mbtreeid) Error: "+ ex." message);
Return to "other";
29}
30}
31
32
The following are the service-side:
1public void query (int lcid, string sqlstring, Hashtable cmdhashtable, ref Basemodel Basemodel) #region public void query (i NT 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 () + "called query" + LCID. ToString () + ", String sqlstring, Hashtable cmdhashtable, ref Basemodel Basemodel)");
ten int i = Cmdhashtable.count;
11//The following constructs stored procedure parameters
sqlparameter[] cmdparms = new Sqlparameter[i];
int j = 0;
foreach (DictionaryEntry de in cmdhashtable)
15 {
CMDPARMS[J] = new SqlParameter (DE. Key.tostring (), DE. Value);
j + +;
18}
Colorful.DBUtility.DbHelperSQL.Query (LCID, SqlString, cmdparms, ref Basemodel);
20}
/--------------------------------------------------------------------
#endregion