Click here to Skip to main content
Click here to Skip to main content

Connecting to Database Express 2005 with VS 2005

By , 2 Aug 2006
 

Introduction

After install Visual Studio 2005, you must install “SQL Server Management Studio Express CTP”. This program plugs into SQL Express 2005. Run SQL Server Management Studio Express CTP and press connect to connect into Server Management Studio Express.

 

 

After connect, you must make a new database and a new table, for example:

make database and give a name for a new database “Practice_1”.

Then, make one table which consist of field “No” and field “Name” and give name for a new table “Checklist”.

After finish making your table, please input same data into your table. Now run your Visual Studio 2005 and make new application windows.  Drag dataGridView into your design form and choose dock in properties become fill. Double click your form and insert these codes:

  

string connstring = "Data Source = .\\SQLEXPRESS;

Initial Catalog = Practice_1; Integrated Security = True";

 

SqlConnection conn = new SqlConnection(connstring);

SqlCommand comm = new SqlCommand();

comm.Connection = conn;

SqlDataAdapter myadapter = new SqlDataAdapter(comm);

DataSet myset = new DataSet();

 

conn.Open();

 

comm.CommandText = "Select * From Checklist ";

comm.ExecuteScalar();

myadapter.Fill(myset, "Checklist");

dataGridView1.DataSource = myset;

dataGridView1.DataMember = "Checklist";

          

conn.Close();

 

The codes above must use “Using System.Data.SQLClient”.

Start Debugging your program and at your dataGridView will come up data which you have filled when making of Database.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

efero
Software Developer (Senior)
Indonesia Indonesia
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralInterestingsussBatman231395 Dec '07 - 9:18 
This is so much simpler than some of the other needlessly complicated examples I have seen on the web.
GeneralThanksmemberGlen Harvy20 Mar '07 - 19:32 
I know it's simple but being a beginner this has helped me a lot - it has cleared up a couple of misconceptions.
 
BTW: You should not dock the datagridview and you should double click the form anywhere BUT the datagridview and add the code to the on_load event.
 
Thanks.
 
Glen Harvy

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 2 Aug 2006
Article Copyright 2006 by efero
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid