Last post Mar 07, 2017 07:26 AM by Shuklaji123
Mar 07, 2017 12:46 AM|Shuklaji123|LINK
I declared my connection string in webconfig like this , <configuration>
connectionString="Server=USER-PC\SHUKLAJI; Database=OnlineExamination; Integrated Security=True; pooling=false; "
<compilation debug="true" targetFramework="4.0" />
and then I am using like this ,
public class DALRegister
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Dbconnection"].ToString());
public int UserDetails(StudentRegistration sr)
SqlCommand cmd = new SqlCommand("prcregisteration", con);
cmd.CommandType = CommandType.StoredProcedure;
int result = cmd.ExecuteNonQuery();
Is it not the best way to use Dbconnection? how to use it, in the best possible manner ? please reply soon. Thanks
Mar 07, 2017 06:04 AM|Prince Srivastava|LINK
Make a common class for connection which you are written in your C# code & call the connection from this common class & make sure that connection will close as well as dispose properly.
Mar 07, 2017 07:09 AM|Shuklaji123|LINK
Thanks , but can you show me some example of the same, as i have never done it. Please do it asap. Thanks in advance !!!!!!!
Mar 07, 2017 07:14 AM|rajeeshmenoth|LINK
The best place for this question is ASP.NET Section.
The following article demonstrate the best way to connect the connection string in ASP.NET Core.
Mar 07, 2017 07:26 AM|Shuklaji123|LINK
These links are not worthwhile. Please tell me a relevant link, I need to apply the common connection class funda to the three-tier architecture, on Online Examination Project Software. Please explain it properly, today itself so that I can implement it