Example of using MySQL stored procedure in adohelper

Source: Internet
Author: User

Adohelper is an abstract data handler class in MS daab. The sqlhelper derived from it is widely used. pdf. NET data development framework implements its own implementation according to the adohelper interface. The following describes how to use it to use the stored procedure.

Two features of PDF. Net: SQL-MAP and oql examples in our project and frameworkProgramMany users are used, but few people directly use adohelper. Therefore, new colleagues found another sqlhelper for convenience. In fact, this is not necessary.

 

Assume that there is a MySQL database test and a stored procedure proc_user1. The following is an example of using the stored procedure.

 

1. First configure app. config/Web. config:

 <?  XML   Version  =  "  1.0  "   Encoding  =  " UTF-8  "   ?>  <  Configuration  >    <  Connectionstrings  >      <  Add   Name   =  "  Default  "   Connectionstring   = "  Server = 192.168.xx.xx; user id = root; Password = xxxx; database = test  "   Providername  =  "  Pwmis. dataprovider. Data. MySQL, pwmis. mysqlclient  "  />    </  Connectionstrings  >  </  Configuration  > 

2. Use the following in the program:

Pwmis. dataprovider. Data. adohelper DB = pwmis. dataprovider. Adapter. mydb. getdbhelperbyconnectionname ("Default");// Pwmis. dataprovider. Data. adohelper DB = pwmis. dataprovider. Adapter. mydb. instance;// MySQL stored procedure test;// The parameter name can be added with the @ symbol, for example, @ page1Dataset ds1 = dB. executedataset ("Proc_user1", Commandtype. storedprocedure,NewSystem. Data. idataparameter [] {dB. getparameter ("@ Page1", 22 )});
 
3. Description:
 
You can use mydb. instance or the connection configuration name to obtain the data access object instance.
 
Mydb. getdbhelperbyconnectionname ("Default");
 
"Default" is the connection name in the configuration file;
 
To use a stored procedure, you only need to pass the stored procedure name, commandtype. storedprocedure, and parameter array.

PS:

Although this article describes the usage of MySQL, if the various databases supported by the pdf. NET Framework can use stored procedures,The usage is consistent..

 

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.