B
BStrick
I've looked around and haven't found a usuable solution to this issue.
I hope that you can provide me with some assistance. I have a
application that calls for the user to select a database/table to view
data from. At that point a datagrid populates with the information.
This works fine except when the user tries to either repopulate that
grid with the same table or with data from a different table.
If the user tries to repopluate from the same table then if should
simply overwrite what was there at first. If they try to populate from
a diffferent table then it should erase the old data and input the new.
Instead what I get when i try to repopulate with the same table is that
it inputs additional data starting at the last row from the frst
attempt. If I am populating the grid from a new table then it will keep
all the previous columns and add the new data to the last column on the
left from the first attemp.
Here is my code
Dim objIntConn As New OleDbConnection
Dim objIntDataset As New DataSet
Dim objIntDataset As New DataSet
Private Sub Populate()
Try
objIntConn.Open()
objIntAdapter.SelectCommand = New OleDbCommand
objIntAdapter.SelectCommand.Connection = objIntConn
objIntAdapter.SelectCommand.CommandType =
CommandType.TableDirect
objIntAdapter.SelectCommand.CommandText =
cmbIntTbl.Text
Try
'objIntDataset.Reset()
'objIntDataset.Tables("IntTable").Clear()
'objIntDataset.Tables.add("IntTable")
'dgIntData.DataBindings.Clear()
Catch
End Try
objIntAdapter.Fill(objIntDataset, "IntTable")
objIntConn.Close()
dgIntData.DataSource = objIntDataset
dgIntData.DataMember = "IntTable"
dgIntData.AutoGenerateColumns = True
dgIntData.AutoResizeColumns()
Catch
MessageBox.Show("An error occured while processing
data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Finally
objIntConn.Close()
End Try
You can see that I've tried a couple of different solutions and none of
them have worked.
Please Help!!
I hope that you can provide me with some assistance. I have a
application that calls for the user to select a database/table to view
data from. At that point a datagrid populates with the information.
This works fine except when the user tries to either repopulate that
grid with the same table or with data from a different table.
If the user tries to repopluate from the same table then if should
simply overwrite what was there at first. If they try to populate from
a diffferent table then it should erase the old data and input the new.
Instead what I get when i try to repopulate with the same table is that
it inputs additional data starting at the last row from the frst
attempt. If I am populating the grid from a new table then it will keep
all the previous columns and add the new data to the last column on the
left from the first attemp.
Here is my code
Dim objIntConn As New OleDbConnection
Dim objIntDataset As New DataSet
Dim objIntDataset As New DataSet
Private Sub Populate()
Try
objIntConn.Open()
objIntAdapter.SelectCommand = New OleDbCommand
objIntAdapter.SelectCommand.Connection = objIntConn
objIntAdapter.SelectCommand.CommandType =
CommandType.TableDirect
objIntAdapter.SelectCommand.CommandText =
cmbIntTbl.Text
Try
'objIntDataset.Reset()
'objIntDataset.Tables("IntTable").Clear()
'objIntDataset.Tables.add("IntTable")
'dgIntData.DataBindings.Clear()
Catch
End Try
objIntAdapter.Fill(objIntDataset, "IntTable")
objIntConn.Close()
dgIntData.DataSource = objIntDataset
dgIntData.DataMember = "IntTable"
dgIntData.AutoGenerateColumns = True
dgIntData.AutoResizeColumns()
Catch
MessageBox.Show("An error occured while processing
data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Finally
objIntConn.Close()
End Try
You can see that I've tried a couple of different solutions and none of
them have worked.
Please Help!!