473,322 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Generated classes based on MSSQL

Disclaimer: This could be considered an ADO question, but, it really is a
question of code maintenance.

I have created a utility app that synchronizes MSSQL tables & stored
procedures as Classes in .NET. So Given the following table structure:
Table Name: ITEM
item_id varchar(20)
description varchar(40)
value int
The following Class would be generated:
'--------------------8<---------------------------------
Class ITEM
Public Structure Fields
Public Const item_id as String = "item_id"
Public Const description as String = "description"
Public Const value as String = "value"
End Structure

Function item_id(dbo as DataRow) as System.String
Return CastDB.ToString(dbo, Fields.item_id)
End Function

Function description(dbo as DataRow) as System.String
Return CastDB.ToString(dbo, Fields.description)
End Function

Function value(dbo as DataRow) as System.Int32
Return CastDB.ToInt32(dbo, Fields.integer)
End Function
End Class
'--------------------8<---------------------------------
So it allows you to use intellisense with your field names, and the classes
are automatically synchronized when if the database changes once it is
setup. The biggest advantage is that when a field (or other object)
changes, everything that uses that object in your app now throws a compile
error.

So I guess my question is this: what are the possible negative issues with
doing this?
Pros:
- allows intellisense with fields, tables, views and stored procedures
- simplifies database-to-code maintenance (shows errors when names change)
- provides easy access to field values
- requires less trips back to Query Analyzer to check data types etc...

Cons:
- complicates maintenance

TIA

~
Jeremy

Nov 20 '05 #1
2 1239
In article <U2*********************@twister.tampabay.rr.com >,
jeremy.cowles[nosp@m]asifl.com says...
Disclaimer: This could be considered an ADO question, but, it really is a
question of code maintenance.

I have created a utility app that synchronizes MSSQL tables & stored
procedures as Classes in .NET. So Given the following table structure:
Table Name: ITEM
item_id varchar(20)
description varchar(40)
value int
The following Class would be generated:
'--------------------8<---------------------------------
Class ITEM
Public Structure Fields
Public Const item_id as String = "item_id"
Public Const description as String = "description"
Public Const value as String = "value"
End Structure

Function item_id(dbo as DataRow) as System.String
Return CastDB.ToString(dbo, Fields.item_id)
End Function

Function description(dbo as DataRow) as System.String
Return CastDB.ToString(dbo, Fields.description)
End Function

Function value(dbo as DataRow) as System.Int32
Return CastDB.ToInt32(dbo, Fields.integer)
End Function
End Class
'--------------------8<---------------------------------
So it allows you to use intellisense with your field names, and the classes
are automatically synchronized when if the database changes once it is
setup. The biggest advantage is that when a field (or other object)
changes, everything that uses that object in your app now throws a compile
error.


Sounds very similar to a typed dataset, which VS.NET can generate for
you automatically:

http://support.microsoft.com/default...b;EN-US;315678

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 20 '05 #2
Nice! I remeber reading something about that back duing the VS.NET media
frenzy. I guess I need to get a good book on ADO.NET, this is really cool.
It's not exactly how my solution works, but I think using the built-in
facilities would be much better for maintainence down the road.

Thanks,
Jeremy
"Patrick Steele [MVP]" <pa*****@mvps.org> wrote in message
news:MP************************@msnews.microsoft.c om...
In article <U2*********************@twister.tampabay.rr.com >,
jeremy.cowles[nosp@m]asifl.com says...
Disclaimer: This could be considered an ADO question, but, it really is a question of code maintenance.

I have created a utility app that synchronizes MSSQL tables & stored
procedures as Classes in .NET. So Given the following table structure:
Table Name: ITEM
item_id varchar(20)
description varchar(40)
value int
The following Class would be generated:
'--------------------8<---------------------------------
Class ITEM
Public Structure Fields
Public Const item_id as String = "item_id"
Public Const description as String = "description"
Public Const value as String = "value"
End Structure

Function item_id(dbo as DataRow) as System.String
Return CastDB.ToString(dbo, Fields.item_id)
End Function

Function description(dbo as DataRow) as System.String
Return CastDB.ToString(dbo, Fields.description)
End Function

Function value(dbo as DataRow) as System.Int32
Return CastDB.ToInt32(dbo, Fields.integer)
End Function
End Class
'--------------------8<---------------------------------
So it allows you to use intellisense with your field names, and the classes are automatically synchronized when if the database changes once it is
setup. The biggest advantage is that when a field (or other object)
changes, everything that uses that object in your app now throws a compile error.


Sounds very similar to a typed dataset, which VS.NET can generate for
you automatically:

http://support.microsoft.com/default...b;EN-US;315678

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele


Nov 20 '05 #3

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

Similar topics

1
by: Ellen K. | last post by:
First of all, I have never done any web-based stuff, so if the following sounds ignorant, it's because I am! So far all our SQL Servers are accessed only over our network and we use Windows...
12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
0
by: vanGogh | last post by:
I have generated classes based on an Xml schema file (xsd) using the XSD.exe tool. My goal is to: - write an application that can parse XML documents - fill objects (based on the generated...
2
by: farseer | last post by:
Hi, First, sorry for this long post, but i'd like to explain my problem in detail... i have generated some classes from my schema. Classes are generated for the root (overall document),...
3
by: MIGUEL | last post by:
Hi all, I'm quite lost with how adding web references to a project creates proxy classes. I've developed a web service with two classes inside and that contains three references to three...
3
by: Nick Gilbert | last post by:
Hi, I have to send an array of prices for a list of products over XML. Currently my XML data looks like this: <ArrayOfProd> <Prod Code="productcode001"> <Prices> <P F="2005-01-01"...
4
by: Fabio | last post by:
An ASP.NET 2.0 web site contains a web form and a web service. The web form consumes the web service. There is a Book class in the App_Code folder. The web service exposes a method that returns a...
3
by: Arpan | last post by:
Web Services make use of proxy classes whose methods & properties are accessed in exactly the same way as how a normal class' methods & properties are accessed. So what for does ASP.NET generate...
1
by: Martin Z | last post by:
I'm getting acquainted with the whole XML/XSD thing, and I've run into a wall. I have a tree of objects that I deserialize from XML for configuration reasons. I have generated XSD from the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.