/ Published in: VB.NET
This code will sow you how to create a new datatable
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
'creating new datatable dim productTable as new datatable("Products") 'build the producs schema products.columns.add("id", gettype(system.int32) products.columns.add("Name", gettype(system.int32) products.columns.add("Address", gettype(system.string) products.columns.add("Tel", gettype(system.string) 'Seting up the ID column as the primary key producttable.primarykey=new datacolumn() {productstable.columns("ID")} producttable.columns("ID").autoincrement=true producttable.columns("ID").autoincrementSeed=1 producttable.columns("ID").readonly=true 'now we are going to populate the datatable with data and for that we need datarow object dim Guste as new Datarow=productstable.newrow() 'set the column values Guste.item("ID")=1 Guste.item("Name")="Nasser M. Tabook" Guste.item("Address")="Sultanate of oman, Dhofar, Salalah , p.o .box 2557" Guste.item("Tel")="123456789" 'Add the datarow to the datatable productstable.rows.add(Guste) ' ' ' ' '------------------------------------------------------------------------------------ 'Another way to fill the newlly created database with data ' ' ' dim Guste as datarow gueste("Name")="Nasser M. Tabook" gueste("Address")="Sultanate of oman, Dhofar, Salalah , p.o .box 2557" gueste("Tel")="123456789" producttable.rows.add("Guest") 'creating new xml file to hold the data producttable.writexml("producttable.xml") 'or you can use producttable.writexml(Server.MapPath("producttable.xml")