Quantcast
Viewing all articles
Browse latest Browse all 12583

Using a connection string with sqlconnection object

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)

        myConnection.Open()

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?

Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>