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?
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.
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.
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.
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???
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:
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.
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.
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
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.
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.
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.
[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.
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
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.
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.
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.
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.
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.
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.