Connection parameters in variable

Super_Grover

Active member
Joined
Apr 7, 2010
Messages
32
Programming Experience
Beginner
Hi all,

My application (vb.net 2008) connects to sql server 2005 express.
When I hardcode the following it works with no problem:

VB.NET:
Dim objconnection As SqlConnection = New SqlConnection("server=.\SQLEXPRESS;database=tstDB;Trusted_Connection=True;")
objconnection.Open()

But ofcourse I don't want the connectionstring hard coded.

So I put the connectionstring in a public variable (gs_ConnRead) and do the following, thing won't work:

VB.NET:
Dim objconnection As SqlConnection = New sqlConnection(gs_ConnRead)
objconnection.Open()

The varable gs_ConnRead is filled with the exact same text as the first hardcoded example, so basicly it's the same.
Now, any ideas why this don't work?

Sorry if this is a very stupid question. But many thanks in advance for helping me!
 
Back
Top