• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 910
  • Last Modified:

VB 2010 - lock/unlock DBF files via BDE (part 3)


I would like to find solution for locking and unlocking dBase III and dBase IV tables (DBF files) from Visual Basic 2010 via BDE v5.01 (Borland Database Engine). I know, this is an old technology, but in this moment I need it for working with the same data like one older application created in Delphi.

I tried to lock tables via ADO, but this did not disable writing to the table for Delphi application, thats why I would like to try to lock tables with the same way, like Delphi application does, via BDE.

Now I know, that I need to use BDE API, but I don't know how exactly.

Until now I have these declarations:

    Private Declare Function DbiOpenDatabase Lib "IDAPI32.DLL" _
        Alias "DbiOpenDatabase" (ByVal lngDBName As Long,
                                 ByVal lngDBType As Long,
                                 ByVal intOpenMode As Integer,
                                 ByVal intShareMode As Integer,
                                 ByVal strPassword As String,
                                 ByVal intOptFlds As Integer,
                                 ByVal lngOptFldDesc As Long,
                                 ByVal lngOptParams As Long,
                                 ByRef lngDBHandle As Long) _
                                 As Integer

    Private Declare Function DbiOpenTable Lib "IDAPI32.DLL" _
        Alias "DbiOpenTable" (ByVal lngDBHandle As Long,
                              ByVal strTableName As String,
                              ByVal strDriverType As String,
                              ByVal strIndexName As String,
                              ByVal strIndexTagName As String,
                              ByVal intIndexId As Integer,
                              ByVal intOpenMode As Integer,
                              ByVal intShareMode As Integer,
                              ByVal intXltMode As Integer,
                              ByVal bytUniDirectional As Byte,
                              ByVal lngOptParams As Long,
                              ByRef lngCursor As Long) _
                              As Integer

Open in new window

But I don't know the values of parameters.

I don't know also, what code I need to put in Button1_Click, when I want to open database, open table, lock table and then for Button2_Click unlock table, close table, close database.

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ' open database

        ' open table

        ' lock table
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        ' unlock table

        ' close table

        ' close database
    End Sub

Open in new window

1 Solution
Sinisa VukCommented:
maybe is this zip helpful if you able to get it (with registration on forum)

You want to lock tabale only or write into table too?


maybe is solution to make delphi dll (internally use bde) and export some custom functions to vb.
skdanAuthor Commented:
I know, my question is difficult because BDE is an older technology, and also there is not easy to find a programmer, who uses combination VB.NET and BDE.

I downloaded that zip file from your first link few days ago. It is very interesting, but written in VB 6, not VB.NET. Maybe I need some documentation for BDE for better understanding its API. Thank you for second link, I will look at it.

I also think, that I will need some part of code writen in Delphi. I will see.

Anyway thank you very much for your effort.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now