Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Explain below attached code line by line:

C#
public void BindData() 
{ 
SqlCommand cmd; 
cmd = new SqlCommand("sp_GetEmployeeDetails", con); 
cmd.CommandType = CommandType.StoredProcedure; 
cmd.Parameters.Add(new SqlParameter("@roll", SqlDbType.VarChar)).Value = DropDownList1.SelectedValue; 
cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar)).Value = TextBox1.Text; 

con.Open(); 
SqlDataAdapter da = new SqlDataAdapter(cmd); 

DataTable dt = new DataTable("Table"); 
da.Fill(dt); 
con.Close(); 
GridView1.DataSource = dt; 
GridView1.DataBind(); 

}
Posted
Updated 23-May-13 1:54am
v2
Comments
[no name] 23-May-13 7:45am    
Why would you need someone to explain your code to to you?
Manfred Rudolf Bihy 23-May-13 7:45am    
Why would I want to do that?

1 solution

I'll tell you in a nutshell

you are executing a stored procedure on the SQL Server by passing in 2 parameters and displaying the results in a DataGridView.

If you want to know it line by line I would suggest that you either Google each command that you want to know more about. Why? As you will learn more that way!

Here is the first one for you
SqlCommand[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900