Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 12th, 2006, 12:46 PM
Registered User
 
Join Date: Sep 2006
Location: Corvallis, OR, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Configuration file name and location

I need to configure the executable so that at each installation the VB program can find the database server, change the connection string to point at the local server named in the config file.
I am sure you have all done this before but to me it is new stuff.

1. What is a good name and location for the configuration file with
the server name?

2. I make the
Public objConnection As New SqlClient.SqlConnection()
at the public class so the I can use it in several forms. True?

But then I need to execute the read config at the Load event so I can
add the server name to the connection string.
3. What is the syntax for modifying the objConnection to use the new string with the server name that I just read from the config file?

objConnection = strConnectionString < This doesn't work.

4. What is the best way to edit the strConnectionString to insert the server name found in the config file?

5. Is there an easy example available of program which does this stuff?

Thanks in advance,

Tom
Reply With Quote
  #2 (permalink)  
Old September 13th, 2006, 03:23 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

1.
<ApplicationName>.cfg

If you put the cfg in the folder with the .exe, then you can find it with app.Path.
If you put it in the Windows directory, you can find it through Environ$("Windir").
You could always put it into C:\Program Files\Common Files\<ApplicationName>\<ApplicationName>.cfg . Then you’ll always know where it is.


2. That is quite useful. It is not always the best, so your situation would be determinative...


3.


4. Use 2 constants for the part of the connection string preceding the server name, and another for all after the server name. Then use
Code:
    strConStr = constConnectStringStart & strReadServerString & constConnectStringEnd
Reply With Quote
  #3 (permalink)  
Old September 29th, 2006, 06:59 PM
Registered User
 
Join Date: Sep 2006
Location: Corvallis, OR, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Brian.
That string concat works great. It runs fine on my pc in debug mode.

I have a new problem. After using click one deployment, the
program can't seem to write an update to the config file that it uses.
The program doesn't create any error messages but no writing to my file occurs.
Is this the way click one applications are supposed to act?
T :(
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access / Modify Configuration File prasanna.nadgir C# 2 October 2nd, 2007 12:14 PM
separate file location for different databases Aprile MySQL 1 September 6th, 2007 04:34 PM
File Location AlexSepahpour ASP.NET 2.0 Basics 0 March 11th, 2007 12:58 AM
Application Configuration File Bob Bedell C# 1 October 7th, 2006 10:56 PM
Save file location code. JpaulH Access VBA 2 June 9th, 2006 07:50 AM



All times are GMT -4. The time now is 12:08 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.