Click here to Skip to main content
15,884,388 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.3K   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.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.CodeDom.Compiler;
using System.IO;

namespace SPTestApp
{
	/// <summary>
	/// Summary description for CodeDOMView.
	/// </summary>
	public class CodeDOMView : System.Windows.Forms.Form
	{
      private System.Windows.Forms.RichTextBox richTextBox1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public CodeDOMView(System.CodeDom.CodeNamespace codenamespace, CodeDomProvider cp)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
         StringWriter writer = new StringWriter();
         cp.CreateGenerator().GenerateCodeFromNamespace(
            codenamespace, writer, new CodeGeneratorOptions());
         richTextBox1.Text = writer.GetStringBuilder().ToString();
         Text += " Lines:" + richTextBox1.Lines.Length;
         
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
         this.richTextBox1 = new System.Windows.Forms.RichTextBox();
         this.SuspendLayout();
         // 
         // richTextBox1
         // 
         this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
         this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
         this.richTextBox1.Name = "richTextBox1";
         this.richTextBox1.ReadOnly = true;
         this.richTextBox1.Size = new System.Drawing.Size(792, 453);
         this.richTextBox1.TabIndex = 0;
         this.richTextBox1.Text = "";
         // 
         // CodeDOMView
         // 
         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
         this.ClientSize = new System.Drawing.Size(792, 453);
         this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                      this.richTextBox1});
         this.Name = "CodeDOMView";
         this.Text = "CodeDOMView";
         this.ResumeLayout(false);

      }
		#endregion
	}
}

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