Solved

Using external database

Posted on 1998-01-25
3
346 Views
Last Modified: 2012-05-04
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?
0
Comment
Question by:Mcblake
3 Comments
 

Expert Comment

by:shachtak
ID: 1453484
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
 

Author Comment

by:Mcblake
ID: 1453485
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
 

Accepted Solution

by:
dpms earned 30 total points
ID: 1453486
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question