This article mainly introduces C # to execute stored procedures and populate the results of the GridView method, combined with an instance of the C # stored procedure operation and the GridView control related operations skills, the need for friends can refer to the following
This article describes a method that C # executes stored procedures and populates the results to the GridView. Share to everyone for your reference, as follows:
Selectsql sq = new Selectsql (); SqlConnection conn = new SqlConnection (SQ.LC); Conn. Open (); SqlDataAdapter rd = New SqlDataAdapter ();D ataset ds=new DataSet (); SqlCommand sqlcom = new SqlCommand ("DBO.SELECTJF", conn); sqlcom. Parameters.Add ("@name", sqldbtype.varchar,20). Value = nametext.text;sqlcom. Parameters.Add ("@sfzh", sqldbtype.varchar,30). Value = Sftext.text;sqlcom.commandtype = Commandtype.storedprocedure;rd. SelectCommand = Sqlcom;rd. Fill (DS); Gridview1.datasource = ds; Gridview1.databind (); Conn. Close ();d S. Dispose (); Rd. Dispose ();