T.R | Title | User | Personal Name | Date | Lines |
---|
2553.1 | | EVTSG8::TOWERS | | Fri May 09 1997 05:05 | 25 |
| Joe, I've ranted on about this before so I'll try not to get too
heated. It really depends what you're trying to do. Databound controls
are fine for prototypes, for small applications with single user
databases but are expensive and dangerous for large-scale systems with
multi-user databases which require you to pay per connection.
Apart from the issue you've discovered about the connection per control
(the first VB3 app I worked on initially used databound controls to
attach to an RDB database until we tested it with several users and
brought the VAX to its knees), there's also the question of data
integrity and locking. Basically, if you have a multi-user db you can't
have databound controls and the data integrity you get from using
locking.
For larger projects there'a also the issue of maintainability. It's so
much easier if all the code is in the code and not hidden in the
properties of some of the controls. You know exactly where to look, but
will the support guy who takes it over know where to look?
The bottom line is use databound controls for fast prototyping,
proof-of-concept type of stuff but write the serious stuff doing the
hard work yourself using DAO or RDO or whatever.
Cheers,
Brian
|
2553.2 | thanks for the reply | HIGHD::MELENDEZ | | Fri May 09 1997 12:45 | 27 |
| Hello Brian, Thanks for the prompt answer, I am sort of new to VB
and have had no training so these things that are simple for others
are somewhat hard for me. I assume that from what your saying that
I can program the code to do the open of the database and then open
and close the tables as needed, also understand about the locking
issue, most of my access will be reads from tables, with only a few
people actualy writting to the database. There are lots of notes here
and I have not been able to come up with a search which gave me what I
was looking for. Can you give me some pointers to notes that will help
or give me some direction. The ultimate aim is to open the connection
once, open and close tables as needed, and lock only on the writes to
the tables. Now for the Stupid question of the day: when the VB
application starts it opens form 1. Can I open the database in the form
and use it from the other forms. such as the following.
dim db as databse
dim ws as workspace
dim rs as recordset
dim sconnect as string
set ws = dbengine.createworkspace("ws1","username"," ")
sconnect =" datbase connedt string"
set db = ws.opendatabse(connect string)
from a different form then
set rs = form1.db.openrecordset(" sql select text)
At the risk of being to far out there, I would ask for examples
of how you have done this.
Thanks for your help and patience.
Joe
|
2553.3 | | EVTSG8::TOWERS | | Mon May 12 1997 11:15 | 34 |
| You've more or less got it, Joe. The only problem is one of scope of
your variables.
There are two approaches you can take. The old fashioned way is to have
a module (eg DataAccess.bas) in which you declare your database
variable using Global instead of Dim. A better approach is to create a
DataAccess class and declare all these variables at the top level there
(ie just after Option Explicit in the General section). Then
concentrate all the DAO or RDO code in that class. In your Global.bas
(or whatever you decide to call it) module declare:
Global objDataAccess As New clsDataAccess
and then in the rest of your code make calls to (Public) routines in
your DataAccess class to do the work, eg
If objDataAccess.Logon Then
Do some processing
objDataAccess.LogOff
Else
Msgbox "Error message"
End If
This approach makes the code much easier to maintain and, if ever the
day comes when you have to target another database/switch from DAO to
RDO etc., it makes finding the code to change much easier.
As to getting more info, the VB help is excellent. Just use the Search
facility.
Note that opening the database using DAO looks something like this:
Set mdbMyDB = WS.OpenDatabase(strDBName, bFalseforshared, _
bTrueforreadonly, strConnectionString)
Cheers,
Brian
|
2553.4 | thanks | HIGHD::MELENDEZ | | Thu May 15 1997 12:51 | 6 |
| Hi Brian,
Thanks for the good ideas. I will give them a try.
sorry for not answering sooner but they removed the modem line in Las
Vegas, Also the username extraction works well thanks for that also.
Joe.
|