Difference between SqlConnection and SqlDataSource for stored procedures
-
Hi, I would like to know the difference in implementation. Both of the ways would run the stored procedure. Which way is better? Thank you. SqlConnection con = new SqlConnection(); SqlCommand inboxDS; con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); inboxDS = new SqlCommand("InsertMessage", con); inboxDS.Parameters.Add("senderUserName", Session inboxDS.Parameters.Add("UserMessage", FCKeditor1.Value); inboxDS.CommandType = CommandType.StoredProcedure; con.Open(); inboxDS.ExecuteNonQuery(); con.Close(); /************************************************************************************************* SqlDataSource inboxDS = new SqlDataSource(); inboxDS.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(); inboxDS.InsertCommandType = SqlDataSourceCommandType.StoredProcedure inboxDS.InsertCommand = "InsertMessage"; inboxDS.InsertParameters.Add("senderUserName", Session["user_n"].ToString()); inboxDS.InsertParameters.Add("UserMessage", FCKeditor1.Value); inboxDS.Insert();