Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2004
    Posts
    4

    Question Unanswered: Database connectivity through VB 6

    Hello to all,

    I am new to this discussion board, but hope you will help me out.

    I have developed a software using visual basic 6 and ms access as backend database.

    This software is for Cyber Cafe Management that is why it has to access the database through networking. It is working fine. But many times the database is not updated properly and the frontend shows the wrong information. Tell me what to do in this situation.

    Bye,
    Hoping for a nice answer.

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346

    Re: Database connectivity through VB 6

    To answer your question you will have to be more specific on what exactly the problem is. In the meantime, here is some code to connect to an Access database, reterive data from Table1, close the recordset and close the connection using Visual Basic with ADO:

    Dim cn as ADODB.Connection
    Dim rs as ADODB.Recordset

    Set cn = new ADODB.Connection

    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Test.mdb;Persist Security Info=False"

    cn.open

    set rs = new ADODB.recordset

    rs.ActiveConnection = cn

    rs.Open "SELECT * FROM Table1"

    rs.Close

    cn.Close

    Set rs=Nothing
    Set cn = Nothing
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Mar 2004
    Posts
    4
    Thanks for ur reply,

    i have already used the same command and it works fine but many times specifically whenever there are many computers are online simultaneously then this command starts bugging. It doesn't update the data properly.

    Can any body tell me what is the reason that it creates a problem while more than one computer are online simultaneously.

    Hoping for a better answer.

  4. #4
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Then that depends on what lock-type you chose, Read-Only, Pessesmistic or Optimistic or BatchOptimistic?
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  5. #5
    Join Date
    Mar 2004
    Posts
    4
    I have not specified any lock type!
    Is it neccesary to specify it?

    Is MS ACCESS limited to low network load?

    Thanks for ur useful replies.

    Bye

  6. #6
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Yes you must specify Lock-types and Cursor-Types or ADO will use the defaults. Here is a summary of your choices:

    4 Lock-Types
    ===============================
    adLockBatchOptimistic 4 Indicates optimistic batch updates. Required for batch update mode.

    adLockOptimistic 3 Indicates optimistic locking, record by record. The provider uses optimistic locking, locking records only when you call the Update method.

    adLockPessimistic 2 Indicates pessimistic locking, record by record. The provider does what is necessary to ensure successful editing of the records, usually by locking records at the data source immediately after editing.

    adLockReadOnly 1 Indicates read-only records. You cannot alter the data.

    4 Cursor-Types
    ===============================
    adOpenDynamic 2 Uses a dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks, if the provider doesn't support them.

    adOpenForwardOnly 0 Default. Uses a forward-only cursor. Identical to a static cursor, except that you can only scroll forward through records. This improves performance when you need to make only one pass through a Recordset.

    adOpenKeyset 1 Uses a keyset cursor. Like a dynamic cursor, except that you can't see records that other users add, although records that other users delete are inaccessible from your Recordset. Data changes by other users are still visible.

    adOpenStatic 3 Uses a static cursor. A static copy of a set of records that you can use to find data or generate reports. Additions, changes, or deletions by other users are not visible.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  7. #7
    Join Date
    Mar 2004
    Posts
    4
    First of all thanks a lot for ur useful reply.

    I have some confusions. Can u please solve them.

    1. I am little bit confused Please tell me that if I want a connectivity in which any user can update any thing any time i mean it should not be locked, then which of the lock should i use.

    2. Is MS Access has some limitations over shared networks.

    Thanks a million for ur useful suggesstions.

  8. #8
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Use adLockBatchOptimistic or adLockOptimistic, these lock-types will let the user update any thing at any time and only lock the records only when you call the update methods. Pessimistic locking locks the record as soon as editing begins.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •