Simple Table To Class Generator

This little utility generates a simple class, a series of properties corresponding to the field name, from the input of an SQL INSERT INTO statement.

I seem to end up doing this from time to time and this utility saves me much time when I need it.

You can download the installer for the program here, or a zipped version of the installer here, and you can download the source code here if you want it. The program currently only produces vb.net code but I may add a C# option later. The code is vb.net using Visual Basic 2010 so it is a VB 2010 project.

NO WARRANTY OF ANY kind IS GIVEN. THE PROGRAM IS SUPPLIED AS IS AND YOU USE IT AT YOUR OWN RISK.

The operation is very simple. Start the program, paste the INSERT statement, select the project visibility and if required the class name and hit convert. Click the clipboard copy button and paste into your project.

The screen looks like this:

simpleclassmainscreen
(Click the Image for a slightly larger/clearer version)

Here is an INSERT statement that I will convert to a class:

simpleclassinput

Paste your statement into the top box. (Sorry you can’t scrape this one as it is an image due to WordPress web translation problems messing with the display even using pre)

simpleclassinput02
(Click the Image for a slightly larger/clearer version)

If you don’t set a name for the class the program will use the name of the table, without the server name etc so in this instance it would give you a class name of:

Friend Class MED_tbl_CustomerConditions

You can set the visibility in the project from three choices: Public, Friend, Private.

Click “Convert to a class” when you are ready. In no time at all you get your class.

simpleclassinput03
(Click the Image for a slightly larger/clearer version)

Currently the converter will handle these SQL types

  • datetime or smalldatetime = Date
  • float or real = Double
  • money, smallmoney or numeric = Decimal
  • varchar, nvarchar, char, nchar, text or ntext = String
  • smallint = Short
  • int = Integer
  • tinyint = Byte
  • bit = Boolean

If you can’t live with my variable naming download the code and fix it. Don’t complain to me!!

The program does NOT recognise any binary, GUID, image or other SQL variant/special types.

Here is the class listing produced above.

simpleclassinput04

2 Responses to Simple Table To Class Generator

  1. Pingback: Simple Table to .NET Class Generator | DA Software

  2. Pingback: Update to Simple Table to Class Generator | DA Software

Feel free to leave a reply (All moderated)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s