Using external database

I have read some Visual Basic database. It refer that I need to create another file for calling driver of that external database in vb.ini or applicationname.ini as following
   
[Installable ISAMs]
Foxpro2.0=c:\windows\system\xbs100.dll

And use SetDataAccessOption command in application. Suppose my application is Mike.exe . Then,

SetDataAccessOption DB_OPTIONINIPATH, "c:\Mike.ini"

Then, I have to create another file which keep index filename information which is tablename.inf.

Do I need to do all of the above for using external database?
McblakeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shachtakCommented:
This is what you have to do if you want to use the external database's own driver. this also means you have to learn the
database's specific access functions.
my suggestion to you is to use the Open DataBase Connectivity standard (ODBC) which allows you to access every database that supports ODBC (most of them does) in a DAO-like manner which means you can declare and use the database and recordset objects  as if you were using a Jet engine. for more details refer to Visual Basic documentation on the subject.
0
McblakeAuthor Commented:
To: shachtak
So, How can I use ODBC in my application using VB4.0? If I use ODBC, I don't need to do whatever in my question,right?

0
dpmsCommented:
Since there are a lot of people who don't know how to connect via ODBC you can still just "go with what you know" and use the ISAM driver to connect. So, covering the issues of your question - it goes something like this...

#1. If connecting to the database is all you want to do. You don't need to make a separate file that will keep track of index issues or call the driver. So don't worry about that.

#2. SetDataAccessOption is only need if the ini file does not have the same name as your appname or is not located in the windows folder. If the appname and appini name are the same and the file is in the windows folder - you don't even need   SetDataAccessOption in your code (Now isn't this easier than you thought).

#3. keep in mind, while your in the programming environment - vb is running off of the vb.ini file which already has an ISAM section. You can just copy and paste this section into your app.ini file so all that work is already done for you (even easier still.

#4. Here's is an example of a program I wrote that connects to dBase III. Keep in mind that you have to change it to connect to Foxpro if that's what you want to do. (Consult the external.txt if you need examples). In this code I did use   SetDataAccessOption because I was using another appini file that did not share the name of my program. I could have just renamed it and not used SetDataAccessOption. (also, keep in mind...  SetDataAccessOption is used in VB3. In VB4 you cannot use this command - it is outdated. The DBEngine object must be used. Also... some databases use the actual file as the DatabaseName some use the folder that holds it. Very Important!! I believe that foxpro is the latter.

Code example:

Sub DBConnect ()
Dim MyDB As database
Dim myTable As table
Dim Response As String

Title = "dBASE Viewer"
Msg = "Database path name?"

SetDataAccessOption 1, "c:\windows\append.ini"
Response = InputBox(Msg, Title)
data1.DatabaseName = Response
data1.RecordSource = "EEInfo"
data1.Connect = "dBASE III;"

Set MyDB = OpenDatabase(Response, 0, 0, "dBASE III;")
Set myTable = MyDB.OpenTable("Tickets")
End Sub

   

             
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.