Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

btrieve with vb6

Status
Not open for further replies.

byRamiX

Programmer
Nov 28, 2006
13
IL
hi, it's my first post here, i hope i'll get what i'm looking for.
well, i'm developing a vb6 application that need to connect a btrieve database.
it's an old version of btrieve.
after 1000s of searches over the net, and after that i found alot of examples i didn't find what i need.
all the example show me how to connect data base where a pervasive client is installed. as the btrieve version is old, it's not working with a client.
the major application is a magic develop application that manage the database and i need to cennect to the data base.
i prefer that the solution wont use ddf file. but i would like also to know how to connect a ddf file!
thanks

 
What version of Btrieve are you using?
It is possible to access Btrieve files without the DDFs but you'll need to know the exact record structure.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
the btrieve version is 6.5
i know the structure of the database and all the fields and tables names.
i will so thankfull if you give me an example for how to do that!
 
Here's the declare for VB6 and Btrieve 6.15:
Code:
Declare Function BTRCALL Lib "wbtrv32.dll" (ByVal OP, ByVal Pb$, Db As Any, DL As Long, Kb As Any, ByVal Kl, ByVal Kn) As Integer
Here's a sample call to open a file:
Code:
Dim pOldFilePos As typPosBlk
pOldFilePos.PosBlk = Space$(128)
lDataBuffer = ""
KeyBuffer = "filename.btr"
KeyBufLen = KEY_BUF_LEN

BufLen = Len(lDataBuffer)

status = BTRCALL(BOPEN, pOldFilePos.PosBlk, lDataBuffer, BufLen, ByVal KeyBuffer, KeyBufLen, 0)
If status <> 0 Then
    MsgBox "Error on Open. Status: " + cstr(status)
End If
Now this code may not work exactly as written. I've cut and pasted parts of the code from a sample I got from Pervasive a while back.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
byRamiX (Programmer) Nov 28, 2006
first of all thanks alot for the effort.
i cut the code and pasted it in my project.
i have some questions about it..
first, i guess the dll that i declare should be installed when i install the btrieve??
2. after i run the example, the vb didn't recognize the "typPosBlk" ... what's wrong with it?
3. he asked me to make the declare as a private.. is it ok?
4. the .btr file... should i create it or where i can find it?

 
To answer your questions:
1. Yes, the DLL should be installed as part of Btrieve.
2. Sorry. Here's the Type declaration:
Code:
Type typPosBlk
    PosBlk As String * 128
End Type
3. How you declare it is up to you and how you are going to use it.
4. The .btr file is your data file. It should already be created. Where it resides is up to the application developer.


Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Usually when VB crashes like that, you've got an uninitialized variable.
I did find a couple of samples on the Pervasive web site (You might need to change the declare to point to WBTRV32.DLL rather than W3BTRV7.DLL. The samples on the site are intended for PSQL V8 and V9 (the current versions).

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
As another alternative you can build the DDF files and then use the activeX controls from Pervasive's SDK. Once you have created the program you can set a property on the activex control that makes it so it does not require the DDF files to be present if that is your decision.

The advantage is you can create a program much quicker as the activex controls bind the control for the database to text boxes. The controls also take care of all binary conversions. I use them for a number of applications and they work very well.

Gil
 
The only problem with the ActiveX controls would be the version of Btrieve being used. The current controls only support PSQL 2000 or newer. The ones that supported Btrieve 6.15 were the Smithware controls and they aren't available anymore as far as I know.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
i found a help file in the bti folder and in it i found a list of dll for accessing a Btrieve workstaion engine from a windows application (16 bit)
here's the list
WBTRCALL.DLL (Windows Requester)
WBTRTHNK.DLL (16-bit to 32-bit Thunker)
WBTRV32.DLL (MicroKernel Interface)
WBTRVRES.DLL (Resource)
the question is how i can know what to declare so i can use those dll's.
i tried to declare them but it says "file not found dllName.dll"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top