Hey I'm trying to learn how to connect a database to a C# project. The
tutorial I am trying to follow says to do the following:
Creating a Database Connection
The first thing you need when retrieving data from a database is, of
course, a database connection. Although you can use the Data Adapter
Configuration Wizard to create a new database connection, the process
is easier to understand if you do it yourself the first time. To do
so, start a new Windows Application project, open the Toolbox window,
and drag a new SqlConnection object onto the form.
The only problem I have is that my toolbox does not have a
Sqlconnection object. I can't seem to find it.
This is very frustrating!
I am using Visual Studio 2005 Professional Edition.
Can anyone help?
Peter Bromberg [C# MVP] - 21 Mar 2008 17:08 GMT
SqlConnection is a class, it is not a toolbox - compatible control. So you
would use it like this:
SqlConnection conn = new SqlConnection(
ConfigurationManager.ConnectionStrings["Northwind"].ConnectionString);
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
> Hey I'm trying to learn how to connect a database to a C# project. The
> tutorial I am trying to follow says to do the following:
[quoted text clipped - 14 lines]
>
> Can anyone help?
pdcjlw1@gmail.com - 21 Mar 2008 17:20 GMT
On Mar 21, 11:01 am, pdcj...@gmail.com wrote:
> Hey I'm trying to learn how to connect a database to a C# project. The
> tutorial I am trying to follow says to do the following:
[quoted text clipped - 14 lines]
>
> Can anyone help?
Ok. So why would my tutorial say to get it from the toolbox. That's
very confusing.
Willy Denoyette [MVP] - 21 Mar 2008 17:45 GMT
> Hey I'm trying to learn how to connect a database to a C# project. The
> tutorial I am trying to follow says to do the following:
[quoted text clipped - 14 lines]
>
> Can anyone help?
Not all Framework components are added to the toolbox per default,
SqlConnection is such component, you need to add it manually, by right
clicking "Components" and select "Choose Items.. " , from the ".Net
Framework Components" dialog select "SqlConnection" to add it to the
toolbox.
Willy.
pdcjlw1@gmail.com - 21 Mar 2008 17:52 GMT
On Mar 21, 12:45 pm, "Willy Denoyette [MVP]"
<willy.denoye...@telenet.be> wrote:
> <pdcj...@gmail.com> wrote in message
>
[quoted text clipped - 28 lines]
>
> - Show quoted text -
Ok. That makes more sense. Thanks.