Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Database Connection

Status
Not open for further replies.

MarcusO

IS-IT--Management
Mar 28, 2001
13
0
0
AU
Hello,

I plan to use a text file containing the database address to be able to determine the database my vb.net application should connect to.

Is it not possible to combine connection guides (e.g. SQLConnection) with a global connection variable (such as the text file?)

Regards,
Marcus
 
Yes you can change your connection string at runtime and just concat the server in it. But I guess you used the wizard to make your connection?

Christiaan Baes
Belgium

"My new site" - Me
 
Dim cs as string = "connection_string"
dim cn as new sqlconnection(cs)
cn.open
' rest of code
' (create a dataset and a sqldataadapter to fill it)
' blah blah
cn.close
cn.dispose
 
Yep, that is right. I used the wizard to create the connection and also the query itself. I suppose I wonder if it is possible to the create the connection object manually and the queries with the wizard?
 
Okay, I figured out how to do it.

I deleted all the connection objects created by the wizard. Then I wrote the connection object manually and declared it as a friend. Finally I set the connection objects on start-up for each form with a wizard created query.

/m
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top