Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

How to Use datatable in asp.net

Posted by Viral Sarvaiya on July 3, 2009

hear i explain the use of the data table

first u have to take a new data table


Dim myDataTable As New DataTable

then take a column


Dim myDataColumn As DataColumn

give the name of the collumns


myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "First column name"
myDataTable.Columns.Add(myDataColumn)

myDataColumn = New DataColumn()
myDataColumn.DataType = Type.GetType("System.String")
myDataColumn.ColumnName = "Second column name"
myDataTable.Columns.Add(myDataColumn)

take a row of the datatable


Dim row As DataRow

give the value to that row


row = myDataTable.NewRow()

row("First column Name") = value
row("Second column Name") = value

and finnaly add that row to the table.


myDataTable.Rows.Add(row)

now you can use mydatatable as data table as per requirement of the project

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: