TeBone 0 Newbie Poster

at a current project I was ask to provide a native access using Visual Basic and the Btrieve API. Since there isnt any actual sample at the website availabel (www.pervasive.com) I thought posting it might help some of you. You can find sample code but almost all of them using VB 6 or older. If you want to download the whole project just check our site (www.dbcoretech.com/?p=364).

Most importand are the declaration of the API itself:

' ------------------------------------------------------------------------------------ '
    ' Btrieve API declaration 
    ' ------------------------------------------------------------------------------------ '
    Protected Declare Function BTRCALL Lib "w3btrv7.dll" (ByVal Opcode As Short, _
                                                            ByVal Cursor As Byte(), _
                                                            ByRef DataBuffer As Byte, _
                                                            ByRef DataBufferLength As Short, _
                                                            ByVal KeyBuffer As String, _
                                                            ByVal KeyLength As Short, _
                                                            ByVal KeyNum As Short) As Short

If you have the declaration you can use the API and fire your requests by using the OpCode parameter.

A basic B_Open would look like this:

OpCode = B_OPEN
        DataBufferLen = 32000
        KeyNum = 0
        KeyBufferLen = 128

        KeyBuffer = "meineTestDatei.btr"
        ' open the btrieve file using the native API function '
        Status = BTRCALL(OpCode, PosBlock, DataBuffer(0), DataBufferLen, KeyBuffer, KeyBufferLen, KeyNum)

hope that gives some ideas - and if you are looking for the full source you can find it here : www.dbcoretech.com/?p=364