Dim sqlConn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) doesn't work

Posted on 2005-04-21
Medium Priority
Last Modified: 2008-02-20
When I type the above dim stmt in I get the message "Type'SqlConnection' is not defined".  The SqlConnection underlined by visual studio is after the AS.  This comes right out of one of the posts here and is verified to the vb.net visual studio help.  What's wrong?  Is my environment screwed up?  My visual studio does not give me SqlConnection as a valid type when keying Dim SqlConn As --------------.  
Question by:JayNichols
  • 2
LVL 35

Accepted Solution

YZlat earned 500 total points
ID: 13837436
Import SQLClient namespace by putting the following stetements at the top of your page:

Imports System.Data
Imports System.Data.SqlClient
LVL 35

Expert Comment

ID: 13837474
or just replace
Dim SqlConn As SqlConnection

Dim SqlConn As System.Data.SqlClient.SqlConnection

Author Comment

ID: 13837586
I surely would have thought all the namespaces would be available in the development environment and included if necessary in the final compilation.  Well, learn something new every day, I guess.

Thanks for the help

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question