469,964 Members | 1,399 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

Where to store connection info ?

Rob
Where is the best place to store database connection info in a vb.net
program ? I do not want to "hard-code" a database name into my program.
Where could I store and retrieve that information ? Also, could you point
in the the right direction as to how one might do it ?

Thanks


Nov 21 '05 #1
5 1021
Rob,

The nice thing from (the first used) connectionstring is that you cannot
store it in a database.

Therefore you have the choise from an XML file, and than make simple a
dataset by hand or the registry (and than it has to be typed the first time
in)

I hope this helps,

Cor
Nov 21 '05 #2
"Rob" <rw*****@comcast.net> schrieb:
Where is the best place to store database connection info in a vb.net
program ? I do not want to "hard-code" a database name into my program.
Where could I store and retrieve that information ? Also, could you
point in the the right direction as to how one might do it ?


..NET Framework Developer's Guide -- Configuration Files
<URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconconfigurationfiles.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Rob
If you store it in an xml file, is there an easy way to get it out ?
Thanks
"Cor Ligthert" <no************@planet.nl> wrote in message
news:uu**************@TK2MSFTNGP12.phx.gbl...
Rob,

The nice thing from (the first used) connectionstring is that you cannot
store it in a database.

Therefore you have the choise from an XML file, and than make simple a
dataset by hand or the registry (and than it has to be typed the first
time in)

I hope this helps,

Cor

Nov 21 '05 #4
Rob,

Creating a dataset, directly typed in this message so watch typos or
whatever,
\\\
dim ds as new dataset
dim dt as new datatable
ds.tables.add(dt)
dt.columns.add()
dt.loaddatarow(new object() {"myconnectionstring"},true)
ds.writexml("myfilepath")
///
Reading it back
\\\
ds.readxml("myfilepath")
myconnectionstring = ds.tables(0).rows(0)(0).tostring
///

That is all.

I hope this helps,

Cor
Nov 21 '05 #5
Use an app.config file.
To read it: strConn =
System.Configuration.ConfigurationSettings.AppSett ings.Get("ConnectionString
")

More info:
http://msdn.microsoft.com/library/de...ingstorage.asp


"Rob" <rw*****@comcast.net> wrote in message
news:--********************@comcast.com...
Where is the best place to store database connection info in a vb.net
program ? I do not want to "hard-code" a database name into my program.
Where could I store and retrieve that information ? Also, could you point in the the right direction as to how one might do it ?

Thanks

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Andrew | last post: by
3 posts views Thread by Hans Merkl | last post: by
1 post views Thread by rdemyan via AccessMonster.com | last post: by
4 posts views Thread by Rob | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.