A
Arpan
The following ASPX code snippet creates a DataSet programmatically right from the scratch:
'create an empty DataSet
Dim objDS As New DataSet("MyDataSet")
'create a new table & add columns
Dim dTable As New DataTable("Users")
dTable.Columns.Add("ID",System.Type.GetType("System.Int32"))
dTable.Columns.Add("FirstName",System.Type.GetType("System.String"))
dTable.Columns.Add("LastName",System.Type.GetType("System.String"))
dTable.Columns("ID").AutoIncrement=True
'add the new table
objDS.Tables.Add(dTable)
'define the Primary Key
Dim keys As DataColumn={objDS.Tables("Users").Columns("ID")}
objDS.Tables("Users").PrimaryKey=keys
'add a row to this table
Dim dRow As DataRow=dTable.NewRow()
dRow(1)="Michael"
dRow(2)="Johnson"
dTable.Rows.Add(dRow)
As such, the above code doesn't generate any errors but how do I access this DataSet i.e. how do I convert it into an actual file or insert it in a database so that I can access the data that it stores (presently it stores only one row - Michael as the FirstName & Johnson as the LastName)?
Thanks,
Arpan
'create an empty DataSet
Dim objDS As New DataSet("MyDataSet")
'create a new table & add columns
Dim dTable As New DataTable("Users")
dTable.Columns.Add("ID",System.Type.GetType("System.Int32"))
dTable.Columns.Add("FirstName",System.Type.GetType("System.String"))
dTable.Columns.Add("LastName",System.Type.GetType("System.String"))
dTable.Columns("ID").AutoIncrement=True
'add the new table
objDS.Tables.Add(dTable)
'define the Primary Key
Dim keys As DataColumn={objDS.Tables("Users").Columns("ID")}
objDS.Tables("Users").PrimaryKey=keys
'add a row to this table
Dim dRow As DataRow=dTable.NewRow()
dRow(1)="Michael"
dRow(2)="Johnson"
dTable.Rows.Add(dRow)
As such, the above code doesn't generate any errors but how do I access this DataSet i.e. how do I convert it into an actual file or insert it in a database so that I can access the data that it stores (presently it stores only one row - Michael as the FirstName & Johnson as the LastName)?
Thanks,
Arpan