How does dataadapter execute the stored procedure?

Source: Internet
Author: User

In fact, dataadapter uses the sqlcommand object to execute the stored procedure:

 

1 Private Dataset getdataset ()
2 {
3
4 Sqlconnection Conn = Dbhelper. getconn (); // Get database connection with help class
5 Sqlcommand cmd =   New Sqlcommand ( " Proc_name " , Conn ); // Obtain the sqlcommand object
6 Cmd. commandtype = Commandtype. storedprocedure; // Specify the name of a stored procedure instead of an SQL statement when the sqlcommand object is created.
7 Dataset DS =   New Dataset (); // Create a dataset for storing the result set
8 Conn. open (); // Open Database
9 Sqldataadapter DAP =   New Sqldataadapter (); // Create a sqldataadapter object
10 Dap. selectcommand = CMD; // Using cmd to execute the stored procedure, sqldataadapter only needs to specify the sqlcommand type (also, deletecommand, insertcommand, updatecommand)
11 Dap. Fill (DS, " Student " ); // Fill Dataset
12 Conn. Close ();
13 Return DS;
14 }

 

Selectcommand is called in sqldataadapter. Fill (), updatecommand, insertcommand, and deletecommand are called in sqldataadapter. Update.

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.