bertino12
asked on
Fill dataset table
I have a dataset that I have created earlier like this:
Public Sub Main()
dim ds as dataset
ds = buildDS()
getCars(ByVal ds As DataSet)
End Sub
Private Function buildDS() As DataSet
Dim ds As DataSet = New DataSet("DS")
ds.Tables.Add(CreateCarTab le)
Return ds
End Function
Private Function CreateCarTable() As DataTable
Dim dt As DataTable = New DataTable("Cars")
dt.Columns.Add(New DataColumn("Manufacturer", GetType(String)))
dt.Columns.Add(New DataColumn("Model", GetType(String)))
Return dt
End Function
I call a function that executes SQL for me and it adds the data to the dataset --> ds.tables(0), but I want to copy the data to the datasets table I created earlier. --> ds.tables("Cars")
How can I make sure this select statement goes into the table, ds.tables("Cars"), that I created earlier and not just to ds.tables(0) ??
Public Function getCars(ByVal ds As DataSet)
Dim sSQL As String = "SELECT MANUFACTURER, MODEL FROM CARS"
ds = OracleHelper.ExecuteDatase t(AppSetti ngs.Connec tionString , CommandType.Text, sSQL, Nothing)
return ds
End Function
Thanks for your time
Public Sub Main()
dim ds as dataset
ds = buildDS()
getCars(ByVal ds As DataSet)
End Sub
Private Function buildDS() As DataSet
Dim ds As DataSet = New DataSet("DS")
ds.Tables.Add(CreateCarTab
Return ds
End Function
Private Function CreateCarTable() As DataTable
Dim dt As DataTable = New DataTable("Cars")
dt.Columns.Add(New DataColumn("Manufacturer",
dt.Columns.Add(New DataColumn("Model", GetType(String)))
Return dt
End Function
I call a function that executes SQL for me and it adds the data to the dataset --> ds.tables(0), but I want to copy the data to the datasets table I created earlier. --> ds.tables("Cars")
How can I make sure this select statement goes into the table, ds.tables("Cars"), that I created earlier and not just to ds.tables(0) ??
Public Function getCars(ByVal ds As DataSet)
Dim sSQL As String = "SELECT MANUFACTURER, MODEL FROM CARS"
ds = OracleHelper.ExecuteDatase
return ds
End Function
Thanks for your time
ASKER
I did that and ds.tables("Cars") has nothing, but ds.tables(0) has the value. How can I put the table into ds.tables("Cars") instead?
ASKER
Im looking for a way not to have to resort to iterating through the ds.tables(0) and copying the contents to ds.tables("Cars"). I would like to just copy the select statements table directly to ds.tables("Cars")
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
All you have to do is in debug mode break on this table and go and read what is in them.
You will see from the data if you are reading the correct table to table data.