Hi friends
I want to know what is use of connection object when we try to create database connection in ADO.Net ?
Thank you.
Use of Connection Object
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kunal VaishyaRank #990 · 2K reputationPosted May 28, 2012, 9:10 AM EDT
sCon = "Connection String";
System.Data.SqlClient.SqlConnection cn = new System.Data.SqlClient.SqlConnection (sCon);
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = " Insert Into Tablename (id,name)values(1,"kunal") ";
cmd.Connection = cn;
cn.Open();
cmd.ExecuteNonQuery();