M
Marty
Hi,
Ok I use the OLEDBConnector and dataset to retrieve data from my Access DB.
I have a problem to read/parse the dataset and I would like to know if I
am using the right object to reach my goal. And I don't want to spend
hours to find out, would you tell me if I'm going in the wrong path?
Private dbConnector As New OleDbConnection
Private Function mySQL() as dataset
Dim strSQLSelect As String
strSQLSelect = "SELECT strName" & _
"FROM tblAdmin " & _
"ORDER BY ID ASC;"
Dim dstDataset As DataSet = New DataSet
Dim Cmd As New OleDbDataAdapter(strSQLSelect, dbConnector)
Cmd.Fill(dstDataset)
Return dstDataset
End Function
Private Sub fillComboBoxAdmin()
Dim dstDataset As DataSet
dstDataset = mySQL()
Dim i As Int32
For i = 0 To dstDataset.Tables(0).Rows.Count - 1
'Fill combobox with dataset content
cbxAdmin.Items.Add(dstDataset.Tables(0).Rows.Item(i))
Next
End Sub
Then the combobox is filled. The user can select a row in the combo box
and if the user hit the "Save" button. Another part of the code will
save the selected combobox row to the database for current user.
Am I doing a good use of the dataset? Because in the sub
fillComboBoxAdmin, I can't get anything out of the dataset.
Thanks
Marty
Ok I use the OLEDBConnector and dataset to retrieve data from my Access DB.
I have a problem to read/parse the dataset and I would like to know if I
am using the right object to reach my goal. And I don't want to spend
hours to find out, would you tell me if I'm going in the wrong path?
Private dbConnector As New OleDbConnection
Private Function mySQL() as dataset
Dim strSQLSelect As String
strSQLSelect = "SELECT strName" & _
"FROM tblAdmin " & _
"ORDER BY ID ASC;"
Dim dstDataset As DataSet = New DataSet
Dim Cmd As New OleDbDataAdapter(strSQLSelect, dbConnector)
Cmd.Fill(dstDataset)
Return dstDataset
End Function
Private Sub fillComboBoxAdmin()
Dim dstDataset As DataSet
dstDataset = mySQL()
Dim i As Int32
For i = 0 To dstDataset.Tables(0).Rows.Count - 1
'Fill combobox with dataset content
cbxAdmin.Items.Add(dstDataset.Tables(0).Rows.Item(i))
Next
End Sub
Then the combobox is filled. The user can select a row in the combo box
and if the user hit the "Save" button. Another part of the code will
save the selected combobox row to the database for current user.
Am I doing a good use of the dataset? Because in the sub
fillComboBoxAdmin, I can't get anything out of the dataset.
Thanks
Marty