Results 1 to 6 of 6

Thread: error

  1. #1
    Join Date
    Feb 2009
    Posts
    29

    Unanswered: error

    Please help, right now i am developing a software i use vb6.0 and msAccess (the version before 2008). my database is placed on D: drive, and my code is working great. But now, they decided to make a network, so now i have to place my database in a network, its path is \\Server\Folder1\database.mdb

    now,there are two computer working with one database, computer one edit Row1 and Computer2 edit Row2 then they both hit update or save or delete, the database should be updated both row1 and row2, this works with me right now. but i am thinking of a possible error, "REAL TIME" error where the row1 will be updated base on the edited record but row2 remains the same(or not updated base what computer2 did) or vise versa.

    is there any solution to prevent this error?

    like having time interval or if the Computer1 click save then computer2 click save, a msgbox or timer will pop up telling computer2 have to wait and count maybe 30 seconds so that the database will be updated, then after that, save what computer2 did.

    I am not thinking of migrating other database because, if i remember it right, i had read oracle book that there are really real time that before computer2 receive the changes from computer1 they have to wait seconds or minute to see the updated database.

    hope you understand what i am trying to explain
    and
    hope there is a way the solve this problem.

    Thanks in advance.

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Access isn't the best choice with multiple users, but, if there are only a few, then it should handle it. (just be sure to make backups religiously.)

    How are you getting the data into the clients? Using ADO directly? (But, if you're using an ADO data control, you have a lot less flexibility - I don't recommend it...)

    You refer to 'row 1' and 'row 2' like access is a spreadsheet. It isn't. The row or rows which are returned have no relationship to a fixed row in the table.

    How are you displaying the data? in a grid of some sort?
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Feb 2009
    Posts
    29
    i use datagrid to show the records.

    this is my code to connect to ms access
    on module:
    Function Load_sales()
    Set db_sales = New Connection
    db_sales.Open "PROVIDER = MSDataShape; Data Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & "D:\Store_Inventory\sales_or.MDB"
    End Function


    on form:
    Private Sub Form_Load()
    Call Load_sales
    Set rs_checksales = New Recordset
    rs_checksales.Open "Select quantity,amount From sales_or Where Barcode = '" & stock_no.Text & "'", db_sales, adOpenStatic, adLockOptimistic
    end sub

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    You're using static recordset cursortypes, which CAN'T change until they're re-queried... Try using a dynamic recordset type per the following:
    Code:
    Private Sub Form_Load()
      dim strSQL as string
    
      Call Load_sales
      Set rs_checksales = New Recordset
      rs_checksales.CursorLocation = adUseClient
      rs_checksales.CursorType = adOpenDynamic
      rs_checksales.LockType = adLockOptimistic
      strsql = "Select quantity,amount From sales_or Where Barcode = '" & stock_no.Text & "'"
      rs_checksales.Open strSQL, db_sales
    end sub
    As I recall, with Access, it can take up to 5 seconds before a change in the database will be reflected in another dynamic recordset. Note that even though the recordset has changed, it won't show up on the datagrid until you resync (or requery) the recordset.

    I just tested this approach against an Oracle 10g server, using the Microsoft Oracle OleDB Provider, and the update is showing up on the datagrid as fast as I can click the refresh button (which calls the rs.resync method.) If you absolutely need for changes to automatically 'show up' at the other client as soon as they are made, you have two approaches you could follow. The first approach is to simply add a timer at each client, and have each client issue a recordset.resync every time the timer event fires, UNLESS the client is in the middle of a database edit, insert, or delete. This approach is very resource intensive, and I can't recommend it. The other approach would be to have the clients signal each other. Possibly, just add a Winsock control to each client and have the client broadcast a message whenever it makes a change to the database. If a client receives such a message, it would resync if it's not in the middle of an edit, or, if the client IS currently editing, set a global flag which the client always checks whenever it ends the current edit.

    If using winsock, you'll have to decide on the protocol to use. If using UDP, you have less overhead, as all the messages are simply broadcast on the network. However, there's no error checking - you don't know if the other clients actually received the message. (a workaround might be to have the 'broadcaster' broadcast the edit notification multiple times, and include a key field so that the receiving client can ignore additional broadcasts of notifications witht he same key. In addition, UDP broadcasts can't propagate across many routers, meaning that the clients would need to be located on the same LAN segment. TCP protocol would allow the sender to know that a client received a message, but, it would take a lot more effort to maintain a list of valid client I/P addresses. (Possibly, at client startup, it updates an IP table in the database with its IP address & timestamp, and removes that IP address as a part of the unload process. Then, when a client updates the data table, it requeries the IP table, and sends TCP messages to each of the IP addresses on the recordset (minus itself, of course.))

    Dynamic cursors require much more in the way of resources than a simple static cursor needs though, from both the server (if one is used,) and the client.
    Last edited by loquin; 03-06-09 at 19:04.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  5. #5
    Join Date
    Feb 2009
    Posts
    29

    url

    is there any tutorial site you know for this winsock?

    this is my first trial to use a winsock. I had visited this site ( A Client server Chat program using VB6 Winsock control tutorial ) but this tutorial is for chat....

    thanks for a lot help from you.

  6. #6
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Sure.

    First, take a look at WinsockVB.Com on archive.org. After you've viewed the tutorials, try things out (on test apps first, to learn how changing a property affects the results.)

    Next, hit the Legacy Communications Forum at our VB sister site, XtremeVBTalk.Com

    There's lots of folks there who have worked a lot with winsock. One of them was Will Barden, who wrote most of the WinsockVB articles. He's not around much these days, but, many of the people that he 'trained' still are.
    Last edited by loquin; 03-07-09 at 01:51.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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