Connect SQL Server to VS
HOW TO CONNECT SQL SERVER TO VISUAL STUDIO
2 Answers
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 attend4days leftRegister
Posted Feb 6, 2014, 11:10 PM EST
Anubhav ChaudharyRank #29 · 42K reputationPosted Feb 7, 2014, 1:04 AM EST
Using System.OleDb;
OleDbConnection x;
OleDbCommand y;
OleDbDataReader z;
private void Form1_Load(object sender, EventArgs e)
{
x = new OleDbConnection(@"provider=sqloledb;Data Source=LAB5\SQLEXPRESS;Initial Catalog=master;Integrated Security=SSPI;");
x.Open();
y = new OleDbCommand("select * from emp", x);
z = y.ExecuteReader();
while (z.Read())
{
MessageBox.Show(z["empno"].ToString() + " " +z["ename"].ToString());
}
x.Close();
}