Implementation method of Idataparameter calling stored procedure in asp.net-practical skills

Source: Internet
Author: User

This article describes the implementation method of Idataparameter call stored procedure in ASP.net, which is a very practical technique in asp.net database design. Share to everyone for your reference.

The implementation methods are as follows:

public string Generateexamepaper (string Papertype, String DriverID, String macaddr) {int i;
  idataparameter[] idata = new Sqlparameter[4];
  Idata[0] = new SqlParameter ("@paperType", Papertype);
  IDATA[1] = new SqlParameter ("@driverID", DriverID);
  IDATA[2] = new SqlParameter ("@MacAddr", macaddr); IDATA[3] = new SqlParameter ("@sReturn", SqlDbType.Char, M, ParameterDirection.Output, False, 0, 0, string.
  Empty, Datarowversion.default,null);
  String AAA = ""; I= dbhelpersql.runprocedureparout ("Pro_generateexamepaper", Idata, out AAA).

  ToString ();
return AAA; ///<summary>///executes stored procedures, returns the number of rows affected///</summary>///<param name= "storedprocname" > Stored procedure name </param&gt
; <param name= "Parameters" > Stored procedure parameters </param>///<param name= "rowsaffected" > Number of Rows </param>/// <param name= "rowsaffected" > Return output value </param>///<returns></returns> public static int Runprocedure (String storedprocname, idataparameter[] parameters, out inT rowsaffected,out str) {using (SqlConnection connection = new SqlConnection (connectionString)) {int result; Connection.
 Open ();
 SqlCommand command = Buildintcommand (connection, storedprocname, parameters); rowsaffected = command.
 ExecuteNonQuery (); result = (int) command. parameters["ReturnValue"].
    Value; str= (int) command. parameters["@sReturn"].
 Value;
  return result;

 }
}

It is believed that this article has certain reference value to the ASP.net program design of our people.

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.