// 1. create a command object identifying
// the stored procedure
SqlCommand cmd = new SqlCommand(
"Ten Most Expensive Products", conn);
// 2. set the command object so it knows
// to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
How to call stored procedures of sql server in c#.what files to be imported and plz give example if possible.?
Try this:
private void Form1_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Data
Source=localhost;Database=Northwind;In... Security=SSPI");
SqlCommand command = new SqlCommand("GetProducts", conn);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds, "Products");
this.dataGrid1.DataSource = ds;
this.dataGrid1.DataMember = "Products";
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment