How to troubleshoot a problem where remoting cannot transfer stored procedure parameters

Source: Internet
Author: User
Tags hash query tostring
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.