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

Posted on 2005-04-21
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 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
    LVL 35

    Accepted Solution

    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

    or just replace
    Dim SqlConn As SqlConnection

    Dim SqlConn As System.Data.SqlClient.SqlConnection

    Author Comment

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now