By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,743 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,743 IT Pros & Developers. It's quick & easy.

How to fill the datatable without using the database?

P: 7
i need to fill the datatable(datagridview) without using the database..
Here is my code.. But i cant able to fill the datatable
[CODE}
Public Sub CreateDatatable()
dtable = New DataTable("purchasedetails_table")

Dim column As DataColumn


column = New DataColumn()
column.DataType = System.Type.GetType("System.String")
column.ColumnName = "SNo"
column.ReadOnly = True
column.Unique = True
dtable.Columns.Add(column)

column = New DataColumn()
column.DataType = System.Type.GetType("System.String")
column.ColumnName = "Item_Name"
column.ReadOnly = True
column.Unique = True
dtable.Columns.Add(column)

column = New DataColumn()
column.DataType = System.Type.GetType("System.String")
column.ColumnName = "Req_Qty"
column.ReadOnly = True
column.Unique = True
dtable.Columns.Add(column)

column = New DataColumn()
column.DataType = System.Type.GetType("System.String")
column.ColumnName = "Req_Date"
column.ReadOnly = True
column.Unique = True
dtable.Columns.Add(column)

dset = New DataSet()
dset.Tables.Add(dtable)


End Sub

Public Sub FillDatatable()
Dim row As DataRow
Dim i As Integer
For i = 0 To DataGridView1.Rows.Count - 1
row = dtable.NewRow()
row("SNo") = i + 1
row("Item_Name") = "Item_Name" + i.ToString()
row("Req_Qty") = "Req_Qty" + i.ToString()
row("Req_Rate") = "Req_Date" + i.ToString()
dtable.Rows.Add(row)
Next i
End Sub
[/CODE}
Aug 24 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.