473,756 Members | 8,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Questions on application design

My company has expressed a desire to convert an existing MS Access
application to a full VB.NET application. My experience is with VB6 so I
want to ask a few questions and get some input on the best way to handle the
following design:

Situation: We want to allow our customers to install with one of the
following options:
1. Use an Access MDB file as the data backend.
2. Use a SQL Server backend. (Either MS SQL, or MySQL)
3. Use an Oracle backend. (This option would be implemented at a later
date.)

Question: What would be the best way handle all data access within all the
forms?
My initial solution: (Don't know if it's the best way)
I have created a Database module structured like so:
**
Property DBType (Specifies the type of backend to use)
Property DBServer (Specifies the SQL Server)
Property DBUsername (Specifies the SQL Server account to use)
Property DBPassword (Specifies the SQL Server account's
password.)

Function ReturnDataset(B yVal SQLString) as Data.Dataset (Return
a dataset object with the specified SELECT command.)
Sub UpdateDatabase( ByVal SQLString) as Boolean (Update the
database using the specified UPDATE/INSERT command)
**

For each table I have created a "Record" class module structured
like so:
**
Property Field1
Property Field2
Property Field3, etc.
Property Dataset as Data.Dataset (Allow me to bind
controls/grids when needed)

Sub OpenData() (Opens a dataset and populates the properties)
Sub UpdateData() (Updates the database with new/changed data)
**

For the data forms I open the form, create a new "Record" class
module, and if appropriate, execute the OpenData routine.
Then I set the control values to the approprate property (through
code).
When appropriate, I then save any changes/updates using the UpdateDa
ta routine.

The idea I had by using the above methodology, is
1. It allows me to specify in 1 place the type of database to use in
the Database module.
2. The record class modules aren't aware of what backend they are
using. They all use the same routines to update and return data. (Using
T-SQL syntax hardcoded into the class module)
Am I on the right track with this type of design? Or is there an easier and
better way of accomplishing this.

Thanks for any info/feedback.
-Matt
Nov 20 '05 #1
2 1863
Cor
Hi Matthew,

This kind of sollutions cannot be handled in detail I think, but when you
ask am I on the right track, I think yes. One of the things that triggered
me direct was that I would look for what the windows integrated security for
users and passwords could do for me.

Another thing was where to hold the user information, for your application,
have a look for that what an XMLdataset as file can do for you or the
registry.

I do not believe that a record class will help you, I think it will give you
only more work.

A dataset is a class that holds rows (records), which come from the datarow
class.

When you are used to it, it is much easier to use than the recordset.

I believe that by building those records classes you are loosing the very
usefull posibilities by instance from dataview, the datarowcollecti on class
and from the datatableclass.

I hope this helps a little bit?

Cor
Nov 20 '05 #2
Matthew,
Situation: We want to allow our customers to install with one of the
following options:
1. Use an Access MDB file as the data backend.
2. Use a SQL Server backend. (Either MS SQL, or MySQL)
3. Use an Oracle backend. (This option would be implemented at a later
date.) The easiest way is to use the OLE DB client in System.Data.Ole Db namespace,
as all those databases support an OLE DB provider. Another option would be
the ODBC client in System.Data.Odb c. Both OLE DB & ODBC are designed to work
with "any" database in a general manner. However each database may still
have unique SQL syntax "features".

However to get better performance from Oracle, SQL Server, and MySql you
should use their respective client in their own namespaces (for example
System.Data.Sql Client for SQL Server). Using the database specific client
complicates things, but not too much. Read on...
I have created a Database module structured like so: Rather then create a Database Module, you may want to consider a Database
Class that has overrideable methods. Each database client (Access, SQL
Server, Oracle) would be a concrete class. As then you can use the Database
Class polymorphically .

The Database Class itself could have a shared method (A Factory Method) that
returns the current instance of the configured Database method. I would
consider implementing this by reading the type itself from the config file.

Something like:

Public MustInherit Class DataBase

Private Shared m_current As DataBase

Shared Sub New()
' Dynamically load an assembly, and create an object
Dim type As Type
type =
Type.GetType(Co nfigurationSett ings.AppSetting s("database")
' appsettings/database = "mynamespace.my class, myassembly"
m_current = DirectCast(Acti vator.CreateIns tance(type), Database)
End Sub

Public Shared Readonly Property Current() As DataBase
Get
Return m_current
End Get
End Property

Public Property DBUsername
Public MustOverride Function ReturnDataset(B yVal SQLString) as
Data.Dataset
Public MustOverride UpdateDatabase( ByVal SQLString) as Boolean
End Class
' Uses the OleDb client
Public Class OleDbDatabase
Inherits Database
Public Overrides Function ReturnDataset(B yVal SQLString) as
Data.Dataset
Public Overrides UpdateDatabase( ByVal SQLString) as Boolean
End Class

' Uses the SqlClient
Public Class SqlServerDataba se : Inherits Database

' Uses the OracleClient
Public Class OracleDatabase : Inherits Database

' Uses the MySqlClient
Public Class MySqlDatabase : Inherits Database

By creating new classes that inhert from Database, each possible in their
own DLL, you can add new database clients without requiring your app to be
recompiled. Note database client specific types (SqlCommand for example)
would not be exposed from the above classes.

NOTE: Rather then having "database" in the appSettings section of
app.config, I would consider creating a new section, that included both the
database, connection string, and other "database" specific settings that are
needed.
Function ReturnDataset(B yVal SQLString) as Data.Dataset (Return
Rather then returning a DataSet consider have the DataSet as a parameter, as
then you could put multiple DataTable, that are inter-related into a single
DataSet.
Function ReturnDataset(B yVal SQLString) as Data.Dataset
Sub UpdateDatabase( ByVal SQLString) as Boolean Rather then accepting SQL strings (that may vary depending on your access
method, I would consider implementing a DataGateway[3] for each table, then
use the Database Class as an Abstract Factory Pattern[4] to get the correct
Gateway for the correct access method.

Also if you are using DataSets, you need 3 parameterized commands to update
the database, an UpdateCommand, a DeleteCommand, and an InsertCommand, see
the four commands on DataAdapter[1].
For each table I have created a "Record" class module structured
like so: You could use a Domain Model[2] as you are describing or a Typed Dataset[1],
IMHO it really depends on how much "business" logic you want in your
objects. I've used Domain Models, Typed Datasets, and untyped Datasets,
depending on the requirements of the project.

Some useful references:

[1] David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS press
is
both a good tutorial on ADO.NET & a good desk reference for later. It covers
data access and DataSets.

[2] Rockford Lhotka's book "Expert One-On-One Visual Basic .NET Business
Objects" from A! Press, provides a framework for data binding to your own
domain (business) objects.
http://www.lhotka.net

[3] Martin Fowler's book "Patterns of Enterprise Application Architecture"
from Addison Wesley press covers both DataSets & Domain models at a higher
level plus a couple of other possibilities for managing your data. The
previous two books go into detail on two of the Martin's patterns...

[4] GOF's book "Design Patterns - Elements of Reusable Object-Oriented
Software" from Addison Wesley, covers a number of useful design patterns for
creating OO programs. GOF = Erich Gamma, Richard Helm, Ralph Johnson, and
John Vlissides. James W. Cooper's book "Visual Basic Design Patterns - VB6.0
and VB.NET" is a good companion book for the GOF book, as James explains the
patterns themselves in both VB6 & VB.NET syntax.

Hope this helps
Jay

"Matthew Hood" <No****@NoSpam. com> wrote in message
news:uc******** ******@TK2MSFTN GP11.phx.gbl... My company has expressed a desire to convert an existing MS Access
application to a full VB.NET application. My experience is with VB6 so I
want to ask a few questions and get some input on the best way to handle the following design:

Situation: We want to allow our customers to install with one of the
following options:
1. Use an Access MDB file as the data backend.
2. Use a SQL Server backend. (Either MS SQL, or MySQL)
3. Use an Oracle backend. (This option would be implemented at a later
date.)

Question: What would be the best way handle all data access within all the
forms?
My initial solution: (Don't know if it's the best way)
I have created a Database module structured like so:
**
Property DBType (Specifies the type of backend to use)
Property DBServer (Specifies the SQL Server)
Property DBUsername (Specifies the SQL Server account to use)
Property DBPassword (Specifies the SQL Server account's
password.)

Function ReturnDataset(B yVal SQLString) as Data.Dataset (Return a dataset object with the specified SELECT command.)
Sub UpdateDatabase( ByVal SQLString) as Boolean (Update the
database using the specified UPDATE/INSERT command)
**

For each table I have created a "Record" class module structured
like so:
**
Property Field1
Property Field2
Property Field3, etc.
Property Dataset as Data.Dataset (Allow me to bind
controls/grids when needed)

Sub OpenData() (Opens a dataset and populates the properties)
Sub UpdateData() (Updates the database with new/changed data)
**

For the data forms I open the form, create a new "Record" class
module, and if appropriate, execute the OpenData routine.
Then I set the control values to the approprate property (through
code).
When appropriate, I then save any changes/updates using the UpdateDa ta routine.

The idea I had by using the above methodology, is
1. It allows me to specify in 1 place the type of database to use in the Database module.
2. The record class modules aren't aware of what backend they are
using. They all use the same routines to update and return data. (Using
T-SQL syntax hardcoded into the class module)
Am I on the right track with this type of design? Or is there an easier and better way of accomplishing this.

Thanks for any info/feedback.
-Matt

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
3345
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to speed. I like books with practical exercises, and also with test questions (like cert books) *2*
8
1309
by: NH | last post by:
Hi, I'm looking for some opinions and advice on designing ASP.Net apps. Let me explain my approach to how I currently design and hopefully you can give me some advice. I create systems for a medium sized business's (200+users) using SQL Server, ASP.Net 1.1 and 2.0. Generally I am very good at database design and development so I feel comfortable putting all of my Business Logic into stored procedures. Is this wrong?
6
1968
by: google | last post by:
I have a few general questions. I am working on a new database to be used within my company. I would like to give a couple of people, particularly HR, the ability to add and delete Access users, and add/remove them to groups, so as people join and leave the company, they can be added/removed as database users at that time. However, I don't want them to have to do it through the standard Access users/groups interface, and I don't want...
13
12812
by: M.Siler | last post by:
Let me clarify from my last post. I am not using these 4 questions as the sole screening method. Currently in, the Tampa Bay area (Florida) there is an extreme shortage of C# developers. We have utilized just about every method known to man to find candidates, including employment firms (which I do not like to use, but when you're back in against the proverbial wall). With the employment firms they will send over just about anyone. So after...
3
1395
by: Sukh | last post by:
I have to design a "Online Test Application" and application is going to display question and answers.All the questons are objective type so there is four answer for each question. My Question is where I shuld store the questions and answers. and how application can pick randomly question. right now I have all question in a text file. Please give me suggestion. I am using C# and asp.net for this. Regards, Sukh.
4
1854
by: Steve | last post by:
I have read a couple articles online, read my Jesse Liberty book but I am still confused as to just what the best practices are for using exceptions. I keep changing how I'm working with them and it has now, after 15k lines of code resulted in a royal mess! It's my hope to ask some specific questions with scenario examples and that some of you might offer a little guidance or general suggestions. 1) string...
14
4111
by: shamirza | last post by:
Question Do ActiveX DLLs made in VB still need the VB runtimes on the machine? ________________________________________ Answer In a word, Yes. Visual Basic does not support what is known as "Static
1
1396
by: dreamznatcher | last post by:
Hello, Not sure whether this is the right group to ask this, but there are so many groups out there I got kinda lost! Please help me out on this career dilemma I'm going through, or kindly forward me to an appropriate group. I am a graduate in Computer Engineering, and am particularly interested in databases. I can chalk out databases in detail on paper and I'm also good at visualizing the development phases of a potential application....
11
1287
by: The Natural Philosopher | last post by:
1/. Can anyone tell me why renaming a function from 'update()' to 'form_update()' makes Safari work when it didn't before? 2/. I would LIKE if possible, to do the following. User is filling in a BIG form. MYSQL/PHP generated. he finds that the option he needs in a select statement isn't there, and needs to be added via a different form.
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.