The .NET Framework type to ADO.NET data type mappings

.NET Framework Type

ADO.NET Database Type

SQL Data Type

String

Varchar

Varchar()

String

Nvarchar

Nvarchar()

String

NChar

Nchar()

String

NText

NText

String

Text

Text

Double

BigInt

Float

DateTime

DateTime

Datetime

DateTime

SmallDateTime

Smalldatetime

Int

Int

Int

Int64

BigInt

Bigint

Int16

SmallInt

smallint

Byte[]

Binary

Binary()

Byte[]

Image

Image

Byte[]

VarBinary

Varbinary()

Byte

TinyInt

Tinyint

Bool

Bit

Bit

Decimal

Decimal

Decimal

Decimal

Money

Money

Decimal

SmallMoney

SmallMoney

Float

Float

Float

Guid

UniqueIdentifier

Uniqueidentifier

Real

Real

Real

Binding Data to Data Web Controls

4GuysFromRolla – Binding a Scalar Array to Data Web Control

The ASP.NET data Web controls can display any data that implements either the IEnumerable interface or the IListSource interface. They are bound through two lines of codes:

  • The object is assigned to the data Web control’s DataSource property
  • The data Web control’s DataBind() method is called

The syntax for displaying a particular field in a data Web control depends upon the data Web control being used.

Two examples:

  • DataGrid
    <asp:DataGrid id="dgArrayAutoGenerate" runat="server"
           AutoGenerateColumns="True">
    </asp:DataGrid>
  • DataList
    <asp:DataList id="dlFibs" runat="server" RepeatColumns="3"
         GridLines="Both" CellPadding="10"
         RepeatDirection="Horizontal">
      <ItemTemplate>
        <b><%# Container.DataItem %></b>
      </ItemTemplate>
    </asp:DataList>

Data Access Tutorials

Microsoft ASP.NET Official Data Access Tutorials – really covers a whole varieties of topics, take the time to read them.

Mastering ASP.NET Data Binding

A fundamental article on ASP.NET Data Binding found on CodeProject  
http://www.codeproject.com/KB/aspnet/Mastering_DataBinding.aspx

Follow

Get every new post delivered to your Inbox.