Click here to Skip to main content
15,881,092 members
Articles / Programming Languages / Visual Basic

SQL Stored Procedure Wrapper & Typed DataSet Generator for .NET

Rate me:
Please Sign up or sign in to vote.
4.50/5 (46 votes)
7 Dec 2002BSD4 min read 380.1K   6.1K   142  
This a small tool that will generate static methods in a class that acts as wrapper for SQL stored procedures. It either outputs a source file or a compiled assembly. Also supports automatic DataSet generation.
using System;
using System.Data;

namespace DBHelper
{
   public class TypeMapping 
   {
      static SqlDbTypeToTypeAssociation map;

      public static SqlDbTypeToTypeAssociation Mapping 
      {
         get {return map;}
      }

      static TypeMapping()
      {
         map = new SqlDbTypeToTypeAssociation();
         map.Add(SqlDbType.BigInt, typeof(Int64));
         map.Add(SqlDbType.Binary, typeof(Array));
         map.Add(SqlDbType.Bit, typeof(Boolean ));
         map.Add(SqlDbType.Char, typeof( String ));
         map.Add(SqlDbType.DateTime, typeof( DateTime ));
         map.Add(SqlDbType.Decimal, typeof( Decimal ));
         map.Add(SqlDbType.Float, typeof( Double ));
         map.Add(SqlDbType.Image, typeof( Array));
         map.Add(SqlDbType.Int, typeof( Int32 ));
         map.Add(SqlDbType.Money, typeof( Decimal)); 
         map.Add(SqlDbType.NChar, typeof( String ));
         map.Add(SqlDbType.NText, typeof( String ));
         map.Add(SqlDbType.NVarChar, typeof( String ));
         map.Add(SqlDbType.Real, typeof( Single ));
         map.Add(SqlDbType.SmallDateTime, typeof( DateTime ));
         map.Add(SqlDbType.SmallInt, typeof( Int16 ));
         map.Add(SqlDbType.SmallMoney, typeof( Decimal)); 
         map.Add(SqlDbType.Text, typeof( String ));
         map.Add(SqlDbType.Timestamp, typeof( DateTime ));
         map.Add(SqlDbType.TinyInt, typeof( Byte ));
         map.Add(SqlDbType.UniqueIdentifier, typeof( Guid ));
         map.Add(SqlDbType.VarBinary, typeof( Array ));
         map.Add(SqlDbType.VarChar, typeof( String ));
         map.Add(SqlDbType.Variant, typeof( Object  ));
      }
   }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License


Written By
Software Developer
South Africa South Africa
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions