Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42731

[RESOLVED] Using a ConnectionString in my winform app

$
0
0
I have a winform (vs2010) and I am running the following code...
Code:

Using connection As New SqlConnection("Data Source=MNT-MGR-2\SQLEX;Initial Catalog=MT;Integrated Security=True")
                                    ' Create the command and set its properties.
                                    Dim command As SqlCommand = New SqlCommand()
                                    command.Connection = connection
                                    command.CommandText = "POPartsPCSUpdate"
                                    command.CommandType = CommandType.StoredProcedure

I am wondering how to reference my connection string that I have setup in the My Project - settings area. I already have that string in there with a name of MTConnectionString. Is there a way to use that instead of having to put this whole string in for every command query I run?


I tried
Quote:

Using connection As New SqlConnection("MTConnectionString")
and I get an error ArgumentException was unhandled by user code. Format of the initialization string does not conform to specification starting at index 0. But it is exactly as the string is above. They are both the same!!
Thanks,
Stac

Viewing all articles
Browse latest Browse all 42731

Trending Articles



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