Solved

Using external database

Posted on 1998-01-25
3
343 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now