i wan create a datatable complex like tis 1!any1 can teach me how to do it?
The datatable consist 5 datacolumn(col1,col2,col3,col4 and col5)
the data of row of col1,col3 and col5 is fix("A","Book","100") and tis same data will insert into 30 row (when the ds.Tables(0) got 30 row)
the data of row of col2 and col4 is take from ds.Tables(0).


The example that show at txt.file is like below:
col1 ,col2 ,col3 ,col4 ,col5
A ,ds.Tables(0).Rows(i) ,Book ,ds.Tables(0).Rows(i) ,100
A ,ds.Tables(0).Rows(i) ,Book ,ds.Tables(0).Rows(i) ,100
A ,ds.Tables(0).Rows(i) ,Book ,ds.Tables(0).Rows(i) ,100
A ,ds.Tables(0).Rows(i) ,Book ,ds.Tables(0).Rows(i) ,100
A ,ds.Tables(0).Rows(i) ,Book ,ds.Tables(0).Rows(i) ,100

Thanks....
i hope can get any suggestion.Please...
Thanks:)

Recommended Answers

All 2 Replies

On the ds you neew to add a new table

ds.Tables.Add("MyNewTable")

Then on ds.Tables("MyNewtable"), you need to add 5 columns

ds.Tables("MyNewtable").Columns.Add("Col1")
ds.Tables("MyNewtable").Columns.Add("Col2")
ds.Tables("MyNewtable").Columns.Add("Col3")
ds.Tables("MyNewtable").Columns.Add("Col4")
ds.Tables("MyNewtable").Columns.Add("Col5")

Then, you need to create a row to be added to the table

Dim MyNewRow As DataRow = ds.Tables("MyNewtable").NewRow

Here you must assign the values to the columns

MyNewRow.Item("Col1") = "A"
MyNewRow.Item("Col3") = "Book"
MyNewRow.Item("Col5") = "100"
MyNewRow.Item("Col2") = ds.Tables(0).Rows(I).Item(SourceItemIndex1)
MyNewRow.Item("Col3") = ds.Tables(0).Rows(I).Item(SourceItemIndex2)

After filling it you must add the row to the table

ds.Tables("MyNewtable").Rows.Add(MyNewRow)

Hope this helps

if i wan repeat the data 100 times,how can i do?
MyNewRow.Item("Col1") = "A"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.