Connecting to Various Database....

zy_abc
04-15-2004, 11:20 PM
Hello All,

I would like to connect to various databases like MySQL, SQLServer, Oracle, MS-Access, DB2 etc.,. using VB6.0 as the front end. Is there any way out, to do dynamic connection & get data from the tables & display it in MS-Flexigrid. Pls help me out.

wengwashere
04-15-2004, 11:34 PM
what do you mean by "doing dynamic connection"?

If you want to have multiple connection strings and probably change them in the future, you could store all of them in an INI file so that you could change them without recompiling your application (IF thats what you want to do)

zy_abc
04-15-2004, 11:46 PM
The user can have any type of database. When the user opens the VB application he should be able to select the type of database (for eg: MS_Access, SqlServer, Sybase, Oracle, DB2 etc.,) Once he selects he should be able to connect to that particular database. Once the connection is established....i should be able to retreive the values of the particular table.

wengwashere
04-15-2004, 11:56 PM
do some conditional statements in ur code...


If User Selects ACCESS
then
set connection string to ACCESS
else if User Selects ORACLE
then
set connection string to ORACLE
...
end if


i suggest you store all connection strings on an INI file... so that when you open a connection, you could just call the connection string that you set...

this works if all DB have the same structure

MKoslof
04-16-2004, 07:21 AM
Just use ADO. You can connect to almost every database engine out there via an ADO connection String. Then, you can prompt the user at first to select their database location and database file. Then, you can analyze the selection and determine what database engine it is. Then, you can build your connectionString on the fly and connect.

For a good resource on ADO and connectionstrings:

http://www.connectionstrings.com

stephenlecompte
04-16-2004, 09:38 AM
everyone talks about making an ini file. How do you that? I only know how to make a .txt file and load it up using:

Open file1 & "database.txt" For Input As #lFile
Input #lFile, connection string
Close #1

Is there any difference with an .ini file and the above?
Thanks for any help

MKoslof
04-16-2004, 07:39 PM
Well there are several potential methods for making an ini file. Review the File I/O tutorial. But, if this ini file is only going to contain text values, just treat it like any other Text file.



Open "C:\Testing.ini" For Append As #lFile
Print #lFile, "my first value"
Close #lFile

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum