473,659 Members | 2,980 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1131
Rob,

The nice thing from (the first used) connectionstrin g 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*****@comcas t.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/cpconconfigurat ionfiles.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******** ******@TK2MSFTN GP12.phx.gbl...
Rob,

The nice thing from (the first used) connectionstrin g 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(d t)
dt.columns.add( )
dt.loaddatarow( new object() {"myconnections tring"},true)
ds.writexml("my filepath")
///
Reading it back
\\\
ds.readxml("myf ilepath")
myconnectionstr ing = ds.tables(0).ro ws(0)(0).tostri ng
///

That is all.

I hope this helps,

Cor
Nov 21 '05 #5
Use an app.config file.
To read it: strConn =
System.Configur ation.Configura tionSettings.Ap pSettings.Get(" ConnectionStrin g
")

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


"Rob" <rw*****@comcas t.net> wrote in message
news:--*************** *****@comcast.c om...
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
1763
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 but still im concerned whether this is the right place to store connection info as in earlier project that was in C++, we use to store the connection info. in registry but the problem with this approach is that your application becomes windows...
4
2700
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 fine, and I can read the connection string in and connect. But at the moment everytime a connection is made to the database to get records, update records insert records etc etc, this file has to be read back in again. Is this an ok way of doing...
10
2404
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 opened, the XML file is read and the userName/password used to establish the sql connection. is this the normal way of doing things, or is it smarter to save these set tings elsewhere, like the registry? if saving to XML is deemed appropriate, should...
4
1566
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 side calendar? (We tried web control calendar. But, each time we selected a date/changed year or month, it would go back to web server. It would increase a lot network traffic.)
3
1734
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 SQL server for session state so I don't think I can store the web service handle there since it's not serializable. Opening up a connection to this particular service is quite slow so I don't want to reopen it for every request.
1
3400
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 and I've even implemented a registration system where the users can upgrade by just receiving a code from me.
8
2553
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 database name. I need to provide the client application with this info for connecting to both a test SQL Server and a production server. I would prefer to NOT hard-code this info into the client application, and App.Config seems rather unsafe as the...
4
2029
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 in the app.config.xml as well, however, the program uses the value that were originally stored in the settings. I have run the Build and Saved the file, I even exited and re-opened the program as well as rebooted the machine.
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.