Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 12th, 2006, 12:46 PM
Registered User
 
Join Date: Sep 2006
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
 
Old September 13th, 2006, 03:23 PM
Friend of Wrox
 
Join Date: Nov 2004
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
 
Old September 29th, 2006, 06:59 PM
Registered User
 
Join Date: Sep 2006
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 :(





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.