473,408 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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 1124
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: faktujaa | last post by:
Hi, Currently im storing the connection info. in XML file on the C drive. the only problem with this is that anybody can open and check the database name. I know encryption can solve this problem...
4
by: Steve | last post by:
C# I am trying to store my connection settings in a config file, mainly so I can easily change the db that the app connects to without doing a release of code. I have the config file sorted...
10
by: Dica | last post by:
i've got an app that needs to connect to sql server and login with a useName/password. currently, my app saves this info in an XML file in plain text (i.e. no encryption). everytime the app is...
4
by: Andrew | last post by:
Hello, friends, I have two questions: (1) In asp.net, where is the best place to store DB connection string? (We have .dll to handle all DB queries.) (2) Any sample source code for client...
3
by: Hans Merkl | last post by:
Hi, I am helping to build a web app that's pretty much a wrapper around a web service. The question now is how to store the handle of the web service object between requests. My client is using...
1
by: rdemyan via AccessMonster.com | last post by:
I'm trying to implement a licensing scheme. There are three types of licenses: Trial - good for 30 to 60 days Interim - good for 1 year Fully Paid - no expiration Everything is working fine...
8
by: Merk | last post by:
I'm looking for a safe and maintainable way to store connection string info (connecting to SQL Server 2005 from .NET 2.0 Windows Forms client app); things like server name or IP address and...
4
by: Rob | last post by:
The app.config in VB 2005 appears to be riddled with bugs.... From solution explorer I right click on the Project | Properties... then I use the grid to add the app settings... AND they are saved...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.