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>
; <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.