How to execute procedure having insert and select command
I am using insert in stored procedure. In same procedure I am select the data from table. I use command object to execute query now I want to get data of select command from that procedure. Please help me

Vithal WadjePosted Sep 24, 2014, 11:15 AM
http://www.c-sharpcorner.com/UploadFile/0c1bb2/insertselectupdate-delete-records-in-single-stored-proce/
Abhishek KumarPosted Sep 24, 2014, 8:30 AM
Please use the below code for retrieving the data from table and binding it to grid view.
using (SqlConnection Conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString))
try
{
SqlCommand Command = new SqlCommand("GetLeaveDeatils", Conn);
Command.CommandType = CommandType.StoredProcedure;
Command.Parameters.Add("@Code", SqlDbType.VarChar, 10).Value = code;
Conn.Open();
SqlDataAdapter DA = new SqlDataAdapter();
DataSet ds = new DataSet();
DA.SelectCommand = Command;
DA.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
finally
{
if (Conn != null)
Conn.Close();
}
Hope this code will help.
Abhishek