Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 27-02-2009
Member
 
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)?
Reply With Quote
  #2  
Old 27-02-2009
Member
 
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.
Reply With Quote
  #3  
Old 27-02-2009
Member
 
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
Reply With Quote
  #4  
Old 27-02-2009
Member
 
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;
 }
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "When to create User Defined Data Type in VB.Net"
Thread Thread Starter Forum Replies Last Post
What are user defined exceptions in Java? Migueel Software Development 5 30-11-2009 07:27 PM
How to create user-defined service on Windows XP killerboy Operating Systems 2 31-07-2009 11:37 PM
end user defined characters Gunter Windows Software 4 13-07-2009 09:36 AM
Create user defined functions in Excel 2007 AbhayD Windows Software 3 24-06-2009 07:05 PM
C# User defined function added in library but no error RadhaV Software Development 2 12-02-2009 07:04 PM


All times are GMT +5.5. The time now is 01:01 PM.