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.
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.
SenthilkumarPosted May 10, 2012, 7:49 AM
See this example, will help you.
http://vb.net-informations.com/dataadapter/dataadapter-selectcommand-sqlserver.htm
Dyson DysonPosted May 10, 2012, 5:57 AM
SenthilkumarPosted May 10, 2012, 5:17 AM
Dyson DysonPosted May 10, 2012, 5:09 AM
Dyson DysonPosted May 10, 2012, 5:01 AM
Krishna GaradPosted May 10, 2012, 4:51 AM
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();
.....