Using a connection string with sqlconnection object RRS feed

  • Question

  • I am developing a windows forms application. Something I haven't done in many years. I have mainly been using ASP.NET to build websites.

    I have added a connection sring to my windows forms project. If I go to My Project->Settings, I can see it there no problem.

    However now I need to reference it in my code so I can loop through records and manipulate data.

    This is how I would normally do this in a web application (where the connection string is defined in a web.config file):

      Dim myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("NameofConnectionString").ConnectionString)

    However when I do that, it does not understand what "configurationManager" is. So how do I define a new sqlconnection and open it using the connection string?
    Thursday, January 31, 2013 9:07 PM


All replies