SQL connection object in 2005

I've been using 2003 for a while and have recently upgraded to 2005.  I can't seem to fine the sqlconnection object in the tool box, where is it??

Steve7423Asked:
Who is Participating?
 
aaronfengConnect With a Mentor Commented:
If all you want to create a SqlConnection you can just do it in the code like this:

SqlConnection conn = new  SqlConnection(/* Add the connection string here */);

SqlDataReader reader = null;

try {
   conn.Open();
   SqlCommand cmd = new SqlCommand("SELECT* FROM Students", conn);
   reader= cmd.ExecuteReader();
   // do stuff with your reader here.
}
finally {
  if (reader!= null) rdr.Close()
  if (conn != null) conn.Close();
 }

Cheers,

Aaron
http://aaronfeng.blogspot.com
0
 
aaronfengCommented:
The way to do it in VS 2005 is to add a new data source in the Data menu.  It will ask you for your connection string and other info in the wizard.  For more info: http://www.ftponline.com/vsm/2005_12/magazine/features/rjennings/


Cheers,

Aaron
http://aaronfeng.blogspot.com
0
 
Steve7423Author Commented:
ok. so the way I see it is that data controls are created via wizards rather than from objects in the tool box like in 2003.

could you show me the way in which you would use this data object and some code to access the data.

0
 
Steve7423Author Commented:
Also, how is this done in code??  without the use of the wizard.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.