Home > Backend Development > C#.Net Tutorial > Detailed explanation of the sample code for C# to execute a stored procedure and populate the results into GridView

Detailed explanation of the sample code for C# to execute a stored procedure and populate the results into GridView

黄舟
Release: 2017-03-21 11:34:30
Original
1182 people have browsed it

This article mainly introduces the method of C#executing stored procedure and filling the results into GridView. It analyzes C# stored procedure operation and GridView control related operation skills in the form of examples. Friends in need can refer to

The example in this article describes how C# executes a stored procedure and fills the results into GridView. Share it with everyone for your reference, the details are as follows:

SelectSql sq = new SelectSql();
SqlConnection conn = new SqlConnection(sq.lc);
conn.Open();
SqlDataAdapter rd = new SqlDataAdapter();
DataSet 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();
ds.Dispose();
rd.Dispose();
Copy after login

The above is the detailed content of Detailed explanation of the sample code for C# to execute a stored procedure and populate the results into GridView. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template