How i can use Store Procedures in mvc ?
can someone bring me an example plz i use this code:
string query = "SELECT * FROM Table1"; string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString;
Hi fr3eddy,
Refer the below code.
DataTable dt = new DataTable(); string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(spName)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; sda.SelectCommand = cmd; sda.Fill(dt); } } }
© COPYRIGHT 2025 ASPSnippets.com ALL RIGHTS RESERVED.