Database connection
Can anyone tell me.hoe to make connection between microsoft sql server and c#, Any simple example of reading some datas from a table in sql and display them in a text box
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
Krishna GaradRank #191 · 12.8K reputationPosted May 10, 2012, 12:51 AM EDT
SqlConnection cn=new SqlConnection("U r Connection String Here...");
cn.Open();
SqlCommand cmd=new SqlCommand("Select * From TableName",cn);
DataSet ds=new DataSet();
SqlDataAdapter da=new SqlDataAdapter(cmd);
da.Fill(ds);
cn.Close();
//display data in textboxes from the dataset
TextBox1.Text=ds.Tables[0].Rows[0]["ColumnName"].ToString();
.....
Dyson Dyson15 reputationPosted May 10, 2012, 1:01 AM EDT
Dyson Dyson15 reputationPosted May 10, 2012, 1:09 AM EDT
SenthilkumarRank #387 · 6.5K reputationPosted May 10, 2012, 1:17 AM EDT
Dyson Dyson15 reputationPosted May 10, 2012, 1:57 AM EDT
SenthilkumarRank #387 · 6.5K reputationPosted May 10, 2012, 3:49 AM EDT
See this example, will help you.
http://vb.net-informations.com/dataadapter/dataadapter-selectcommand-sqlserver.htm