Hi friends
I want to know what is use of connection object when we try to create database connection in ADO.Net ?
Thank you.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kunal VaishyaPosted May 28, 2012, 1:10 PM
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();