Results 1 to 4 of 4

Thread: When to create User Defined Data Type in VB.Net

  1. #1
    Join Date
    Feb 2009
    Posts
    40

    When to create User Defined Data Type in VB.Net

    I have many different objects in my project like Events, NewsArticles, Subscribers, MailingLists, Addresses, Venues, FAQ collections, FAQQuestions, Songs, Statistics, Different types of reports, Categories of different types (Events, Venues) and so on. When should I consider using objects (classes) or data types (structures)?

  2. #2
    Join Date
    Apr 2008
    Posts
    193

    Re: When to create User Defined Data Type in VB.Net

    We basically create the user defined data type in the following situatione:

    1. The object should just carry data from 1 layer to another and that is it.
    2. There should be a business layer that the object is given to. This deals with any custom logic/validation to the object with any business rules needed to be applied.
    3. Once the business layer gets done with the object, it sends it to the data access layer which does any database validation/rules and sends it to the database.

  3. #3
    Join Date
    Mar 2008
    Posts
    227

    Re: When to create User Defined Data Type in VB.Net

    The process of creating a UDT begins with creating a .NET class that supports the proper API. Creating and using a UDT comes in two phases: creating the library and registering the UDT with SQL Server. The first step is to create your new data type in Visual Studio .NET. The listing for this article shows how to create a Social Security Number data type. When you create your UDT you will do the following:

    • Create a new class library
    • Import assembles
    • Add two attributes to your class (Serializable() and SqlUserDefinedDataType)
    • Implement the INullable interface
    • Add required methods and properties to your class
    • Compile your class
    • Register your class library with SQL Server

  4. #4
    Join Date
    Jan 2006
    Posts
    211

    Re: When to create User Defined Data Type in VB.Net

    Users can define their own data types. Classes and structure definitions fall under user defined data types. If we want to play with user defined datatypes and ViewState, then really we need to concentrate on defining them.

    Code:
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    
    namespace CodeProject
    {
     public class WebForm1 : System.Web.UI.Page
     {
        private void Page_Load(object sender, System.EventArgs e)
        {
            UserClass UC=new UserClass();
           this.ViewState["Key"]=UC;
           Response.Write("View State is workng..");
          }
    
          #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
               //
    
           // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    
           //
    
           InitializeComponent();
           base.OnInit(e);
          }
          private void InitializeComponent()
        {    
           this.Load += new System.EventHandler(this.Page_Load);
         }
        #endregion
     }
    
     public class UserClass
     {
          public UserClass()
        {
            _number=1;
            _name="cp.com";
          }
          private int _number;
          private string _name;
     }
    }

Similar Threads

  1. What are user defined exceptions in Java?
    By Migueel in forum Software Development
    Replies: 5
    Last Post: 30-11-2009, 07:27 PM
  2. How to create user-defined service on Windows XP
    By killerboy in forum Operating Systems
    Replies: 2
    Last Post: 31-07-2009, 11:37 PM
  3. end user defined characters
    By Gunter in forum Windows Software
    Replies: 4
    Last Post: 13-07-2009, 09:36 AM
  4. Create user defined functions in Excel 2007
    By AbhayD in forum Windows Software
    Replies: 3
    Last Post: 24-06-2009, 07:05 PM
  5. C# User defined function added in library but no error
    By RadhaV in forum Software Development
    Replies: 2
    Last Post: 12-02-2009, 07:04 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,678,152.45005 seconds with 16 queries