Results 1 to 21 of 21

Thread: [RESOLVED] how to run project on NETWORK ??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Resolved [RESOLVED] how to run project on NETWORK ??

    hello, all.

    I have created a project for my client using DAO. till now he is the only user.
    now they are 3 users. what kind of changes I have to make in my codeing to run my project on LAN / Network ?

    I don't have any idea regarding same, so if any one can help me on this?


    Thank you in advance.


    Kaushal

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: how to run project on NETWORK ??

    The only real change should be in connecting to the database, which should be in a central location where everyone can get to it. The program itself should be installed on each person's computer.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,149

    Re: how to run project on NETWORK ??

    Agree totally with techgnome...BUT, there are some intricacies to consider when having multiple people access a database simultaneously. That hinges also on what type of database system you are using, and how it handles locking/unlocking of tables. A quick Google search of your type DB and "multiple access" might provide some great advice.

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: how to run project on NETWORK ??

    Hmmm, I'm of the opposite view.

    My primary application is typically executed by 4 to 10 users at each site. I just "copy" the whole thing onto a network location (the executable, the database, everything). And then I teach the users how to make a shortcut to the executable.

    Now, having said this, I've worked very hard to keep my application portable (i.e., no installation needed). If you're just using the DAO (and no OCX controls, and no other ActiveX components), your executable will be portable right out of the box. If you're using OCX controls or other ActiveX components, then things get a bit more difficult to stay portable, but it's doable as per this tutorial.

    A VB6 application will run perfectly fine from a networked location, especially if all the connections are through ethernet cables. If you have WiFi connections, things may be somewhat sluggish, and I wouldn't actually recommend that without some additional considerations.

    Good Luck,
    Elroy

    EDIT1: Also, the DAO, in a multi-user environment needs a bit of tweaking to turn off all of its (once-upon-a-time fancy) forward-reading cache. It can occasionally cause unwanted file locks. However, all of this is a completely separate issue of how to setup a VB6 application for network operations. But I'll talk more about that if you ask.
    Last edited by Elroy; Nov 21st, 2017 at 12:21 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,149

    Re: how to run project on NETWORK ??

    My primary application is typically executed by 4 to 10 users at each site. I just "copy" the whole thing onto a network location (the executable, the database, everything). And then I teach the users how to make a shortcut to the executable.
    All well and good (I see your view differs from tg's)...however, how do you handle two or more users ("accidentally") accessing (writing to/reading from) any specific table. You have to have some sort of control there, yes???

    And that was MY only real point.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: how to run project on NETWORK ??

    DAO pretty much died in 1998. I have no memory of whether DAO can manage this or how to go about it:

    Normally you'd be careful to use transactions in order to group associated "updates" and of course also set appropriate values for Connection Properties such as:

    Code:
    Jet OLEDB:Transaction Commit Mode
    Jet OLEDB:Implicit Commit Sync
    Jet OLEDB:User Commit Sync
    Jet OLEDB:Lock Delay
    Jet OLEDB:Lock Retry

    You may also want to open the database with Alcatraz locking (row-level locking). That means

    Connection Properties:

    Code:
    Const JET_DATABASELOCKMODE_ROW = 1
    CN.Properties("Jet OLEDB:Database Locking Mode").Value = JET_DATABASELOCKMODE_ROW
    Recordset Properties:

    Code:
    Const JET_LG_ALCATRAZ = 1
    RS.Properties("Jet OLEDB:Locking Granularity").Value = JET_LG_ALCATRAZ
    Otherwise you get page-level locking and a lot more collisions.

    Speaking of collisions, you still need to handle errors that may arise if your Delay * Retry is exceeded.


    You also want to avoid using client-side Recordsets for anything but small-rowset returning queries. Otherwise you'll have far more network traffic than required.

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: how to run project on NETWORK ??

    Hi Sammy,

    Yeah, for me, I use optimistic locking with no bound controls.

    And, as far as locking/collisions, they're rare in my case but they can happen. To deal with that, I use some "area locking" that's external to the DAO (or MS Access). I'm willing to share those procedures if asked.

    Regarding the DAO, all I know is that it's fully supported on every version of Windows I run into (since at least XP and through the latest version of Win10), and that Microsoft is still maintaining and writing support pages for it, as evidenced quite recently here, and definitely more recent than 1998 here and here.

    kaushal.jam, good luck with your work.

    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  8. #8
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

    Re: how to run project on NETWORK ??

    Hi,

    I go a diffrent way with multi Users. I ..well how will I call it...
    I 'stretch the Program"' the way the User must search and then select a Record

    example for a Customer record
    a) the User must enter Data in a "Search Form" first (enter Letter firstname)
    b) Search Form closes
    c) the Result(s) are displayed in the "Results Form"
    here the User can select the Customer, but also can see which Customer Records are in use.

    see Image of the Results Form
    Name:  Record Locked.jpg
Views: 621
Size:  31.5 KB

    it is not possible to select (OK button disabled) the customer if this Record is already in use.


    there are drawbacks with this method
    more programming effort... etc...


    regards
    chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  9. #9
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: how to run project on NETWORK ??

    So, there are several issues here, all depending on the specific needs:

    • Where should the executable reside?
    • Should you try and go portable or stick with an installer for the program?
    • What type of data access technology should be used (ADO, DAO, etc.)?
    • What type of backend-database should be used (MDB, ACCDB, SQL server of some kind)?
    • What type of record/area locking should be implemented?


    Kaushal, these are all decisions you must make. Although, they don't all need to be made for-all-time on your first pass at going networked. For instance, you could certainly start with an MS-Access database and then upgrade to a SQL server later.

    With optimistic record locking, a first pass at a network implementation should be quite straightforward. However, beware that you may have data collisions (user#1 opens data for editing, user#2 opens data for editing, user#1 saves edits, user#2 saves edits and steps on user#1's edits).

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Re: how to run project on NETWORK ??

    THank you all for your reply.

    but I am totally clueless.

    right now I am using DAO only. in back hand I am using ms access (.mdb) and for reports CR8.5.

    I have added Microsoft ActiveX Data Object 2.5 Library to my project.
    I have created a ODBC connection called MMSTest, I tried with following code but not total disaster...

    Code:
    Set db = OpenDatabase("Microsoft Access Driver (*.mdb)", "MMSTest", App.Path & "\VoucherMS.MDB")
    after using above code I got runtime error 3421 - data type conversion error.


    Code:
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                              "Data Source=" & App.Path & "\VoucherMS.mdb"
    after using above code I got runtime error 3055 - not a valid file name. btw file name is correct.

    so, please help me asap.


    Thank you,

    kaushal

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Re: how to run project on NETWORK ??

    [QUOTE=techgnome;5235369]The only real change should be in connecting to the database, which should be in a central location where everyone can get to it. The program itself should be installed on each person's computer.

    very true, tg but how to do that?

    plz. help if possible.

    thank you

    kaushal

  12. #12
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: how to run project on NETWORK ??

    What we need here is an example.
    This thread
    http://www.vbforums.com/showthread.p...-Network-(LAN)
    appears to contain a link to one (see post 16 from gibra)
    http://nuke.vbcorner.net/Progetti/VB...T/Default.aspx

    You have to register to his web site before you can get to the downloadable project
    I tried registering on his web site back in 2013, and failed.
    I had better luck this time, and managed to get to the web page, and download it.
    (Just downloaded, so I have not run it yet)
    In the off chance that you too have trouble registering, I will provide you with more incentive by showing you a translation of the web page that describes it -

    Project Login is a small sample application which shows how manage a database (Access 2002-2003) using ADO 2.5.
    The purpose of this project is to provide support to less experienced developers in the design of data-oriented applications using a database. In practice it is a kind of 'template' project that can be used as a basis to develop or expand their applications.
    Especially focusing on the management of data concurrency which is a critical step of the multi-user environments.
    I hope this project helpful.
    The project can be downloaded and modified freely without any restrictions.
    The author disclaims any and all liability.
    Optimistic concurrency
    To test for optimistic concurrency (multi-user on LAN) perform the following steps::
    - Compile the project
    - Start 2 sessions of the compiled program, taking care to connect:
    - in the first session with: user1 / password1
    - in the second session with: user2 / password2
    - open the same record in both sessions
    - edit and Save the data in the last session, opened with user2 (the second)
    - now edit the data and save in the first session opened with user1.
    A message will indicate that the changes isn't allowed because the data are already been changed by user2.
    To be able to edit the data, please refresh the original data from the database (Refresh button).
    Optimistic concurrency
    https://msdn.microsoft.com/it-it/lib...v=vs.110).aspx

    Rob
    PS If you browse the site, there appears to be a follow on project called ADO DataProject 2.0.1
    I am not saying that the OP (kaushal.jam) needs to download that, but other members may be interested
    Last edited by Bobbles; Dec 1st, 2017 at 03:38 AM. Reason: Additional download suggestion

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Re: how to run project on NETWORK ??

    Bobbles, Thank you for your reply.

    i am still clueless....nothing happend!!

    manage to login http://nuke.vbcorner.net/Progetti/VB...T/Default.aspx and also download that ProjectLogin4.zip. but my solution was not there.

    so, plz. plz. guide / help me with my problem...


    Thanks

    kaushal jhaveri

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Re: how to run project on NETWORK ??

    Once again Hello all,

    i have created ODBC and after that when i am executeing my code, i got following error...

    Code...

    Code:
    Set db = OpenDatabase("ODBC;Driver={Microsoft Access Driver (*.mdb};SERVER=" & "TestMS") ' & ";DATABASE=" & "VoucherMS_OLD.MDB" & ";UID=" & "administrator" & ";PWD=" & "unisol@123")
    Error...

    Run-time error '3043':
    disk or network error.
    so, what is wrong in my CODE line, plz. plz. HELP...

    Thank you in advance

    - Kaushal

  15. #15
    Frenzied Member
    Join Date
    Dec 2008
    Location
    Melbourne Australia
    Posts
    1,487

    Re: how to run project on NETWORK ??

    If you used ADO, you are more likely to get help.

    A bit over a decade ago, I took myself aside, and told myself to switch to ADO.
    I had a very large project that had many DB connections, and they were all DAO.
    The good news is, you do not have to convert them all at once.
    You can add a new form, and use only ADO in it, and it still runs happily whilst all the other Forms are using DAO.
    And one by one you can convert your DAO forms to use ADO.

    Now who could argue with that ?
    Rob

    PS It may have no bearing, but I have a policy of never maintaining a connection to the DB.
    Last edited by Bobbles; Dec 13th, 2017 at 05:54 AM.

  16. #16
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: how to run project on NETWORK ??

    Don't use ODBC

    You can open the Access DB directly using the Jet drivers

    As for what is wrong with your code, there is no path specified for the mdb file.
    You also have a comment character in there so part of that line is treated as a comment. I would expect it to throw a compile error and not run at all.

  17. #17
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,871

    Re: how to run project on NETWORK ??

    Hi kaushal,

    As I stated in post #4, my primary application runs on networks and uses DAO. It has run absolutely fine for years.

    Now, for me, I just put everything in some folder on the network, with the EXE and the MDB being in the same folder. That makes things very easy.

    And as DataMiser says, no need for ODBC. In fact, it runs exactly the same as if it weren't on a network.

    If you're not comfortable doing the work necessary to make your application portable, then just "install" it on each user's computer, and then change the shortcut so that they point to the EXE that's out on the network.

    In my eyes, none of this is really that big a deal.

    I guess one more thing I should mention is how to deal with computers that are hooked to the network via WiFi. That does present some challenges, as you don't want an EXE to be constantly adding network traffic if that traffic is all over WiFi. I have an option whereby the user can setup an INI file that specifies where the MDB file is. That way, I can have the EXE local, and the MDB on the network. The INI file just has one simple entry which is the path of the MDB file.

    Good Luck,
    Elroy


    EDIT1: Here's also some code I execute before I open my database. In a multi-user environment, it makes the DAO work a bit better. The DAO has some forward-read-caching built into it which occasionally causes some conflicts for users. With today's hardware, it's just not needed, and the following turns off this forward-read-caching.

    Code:
    
    Public Sub SetDaoRegistryOverrideOptions()
        ' The following makes sure that the DAO.DBEngine properties are set correctly.
        ' Documentation is below.
        ' These first three really shouldn't be used since the CommitSync is set.
        DAO.DBEngine.SetOption dbExclusiveAsyncDelay, 2000
        DAO.DBEngine.SetOption dbSharedAsyncDelay, 0
        DAO.DBEngine.SetOption dbFlushTransactionTimeout, 500
        '
        DAO.DBEngine.SetOption dbUserCommitSync, "yes"
        DAO.DBEngine.SetOption dbImplicitCommitSync, "yes"
        DAO.DBEngine.SetOption dbLockRetry, 20
        DAO.DBEngine.SetOption dbPageTimeout, 5000
        DAO.DBEngine.SetOption dbMaxLocksPerFile, 9500
        DAO.DBEngine.SetOption dbLockDelay, 100
        DAO.DBEngine.SetOption dbRecycleLVs, 0
    End Sub
    
    Also, the full version (with comments) is attached.
    Attached Files Attached Files
    Last edited by Elroy; Dec 13th, 2017 at 10:16 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Re: how to run project on NETWORK ??

    Thank you all for your reply.

    Bobbles, totally agreed with you but right now it's a very long process for me. I will definitely convert my codes to ADO but right now I need help in DAO.

    DataMiser and Elroy, as per both of you I can use "Access DB directly using the Jet drivers". I tried but I got " runtime error 3055 - Not a valid filename"...so, can you help me with sample code please.

    plz. help.

    thank you,

    kaushal

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Re: how to run project on NETWORK ??

    I am totally clueless and don't know how to deal with this problem?

  20. #20
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,046

    Re: how to run project on NETWORK ??

    Hi,

    put this in a Modul...

    Code:
    Option Explicit
    Public dbP As Database
    Public Const progname = "MyProgram"
    Public rsTable As Recordset
    
    
    Public Function openTheDataBase() As Boolean
    Dim dbPath As String
    
    On Error GoTo dbErrors
    
    dbPath = App.Path & "\YourDataBase.mdb"
    Set dbP = DBEngine.Workspaces(0).OpenDatabase(dbPath, False)
    Set rsTable = dbP.OpenRecordset("yourTable", dbOpenTable)
    
    openTheDataBase = True
    Exit Function
    
    dbErrors:
    openTheDataBase = False
    MsgBox (Err.Description)
    End Function
    and this in a Form for Test..

    Code:
    Private Sub Form_Load()
    
    If (Not openTheDatabase()) Then
      MsgBox "Sorry - the database could not be opened."
           'terminate the program unconditionally
           Else
           MsgBox "Database open"
    End If
    
    End Sub
    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  21. #21

    Thread Starter
    Lively Member
    Join Date
    Jul 2012
    Posts
    90

    Re: how to run project on NETWORK ??

    Thank you very very much, CHRIS. Your Code Works PERFECTLY.


    - Kaushal

Posting Permissions

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



Click Here to Expand Forum to Full Width