Archived

This topic is now archived and is closed to further replies.

DarkAstimarious

Newb with a ?simple? question

Recommended Posts

Hey im basicallt just using vb 6.0 for one project and i need to keep track of profile numbers the application goes likethis a person has a troubleshooting problem with a product and wants to get an awnser they fill out a form and the form automatically needs to be numbered sequencially and stored so like prob #1 number - 000001 prob #2 number - 000002 any help would be great considering i know little or online references would also be of tremendous help

Share this post


Link to post
Share on other sites
There are several ways. The easiest is if you are using a database on a server then you just stick a table out there with one row saying the last number used. Only slightly more difficult is to use a file server with a file containing the last number used. The main thing is to not open the file when the program starts and close it when you exit. If you do that then no one else can run until the current user closes the application which might be after then get back from lunch or return to work the next day. Instead when you need a number open it, read it, update it, write it back and close it. All without waiting for the user to do anything.

If you have a high level of concurrency using a file server will introduce what may be a noticable delay. It may only take a 10th of a second to get a number, but if you have a thousand people getting numbers then you have someone waiting 100 seconds. A database server is the easiest way to solve that, but failing that then you need to use network communications, i.e. sockets, to call an application that is responsible for maintaining the number. It opens the file and reads it when it starts up then leaves it open. Openning and closing the file is most of the work. When it hands out a new number it also writes the number to the file. That way if the server crashs you can pick back up where you left off.

Chances are you don''t have a level of concurrency that requires anything like that and a simple file on a file server accessible from all clients will do well enough. There are some issues that can arrise in differant circumstances which is why a database server would be preferable. It is built for concurrency and handles those scenerios for you.

Share this post


Link to post
Share on other sites