Hi there,
I wonder if somebody could please point me in the right direction.
I have a form which has a DataGridView on it. The DataGridView is populated with data from an
MS access database on 'form load' with no problems.
I have another form (frmSettings) which allows a user to modify various settings.
One option they have is to browse to a different MS Access database (*.mdb).
Part of this works fine... the new database name is held, what I can't seem to get it to do though,
is to refresh the DataGridView with the data from the new .mdb file on the frmMain when I click
on my 'Save & Exit' button on my frmSettings.
If I close and re-open the application, it remembers the name of the other .mdb I selected through
my settings form and populates the DataGridView with the data from the new .mdb.
I can only imagine that there is a problem with the method I am using to try and re-populate /
refresh the DataGridView.
The name of the table in the Access database is 'tblresults'
I have explained the issue as well as I can, any help that anybody can offer is much appreciated.
ADDED... 13/05/2010 14:03 GMT
I have hunted around a bit and I think the question I should really be asking is......
I wish to empty an existing DataSet (_DBASE_ConnectionDataSet) and then fill the emptied DataSet with data from my newly attached .mdb
I wonder if somebody could please point me in the right direction.
I have a form which has a DataGridView on it. The DataGridView is populated with data from an
MS access database on 'form load' with no problems.
I have another form (frmSettings) which allows a user to modify various settings.
One option they have is to browse to a different MS Access database (*.mdb).
Part of this works fine... the new database name is held, what I can't seem to get it to do though,
is to refresh the DataGridView with the data from the new .mdb file on the frmMain when I click
on my 'Save & Exit' button on my frmSettings.
If I close and re-open the application, it remembers the name of the other .mdb I selected through
my settings form and populates the DataGridView with the data from the new .mdb.
I can only imagine that there is a problem with the method I am using to try and re-populate /
refresh the DataGridView.
The name of the table in the Access database is 'tblresults'
VB.NET:
strDBAseName = "C:\Temp\NewDBase.mdb"
If System.IO.File.Exists(strDBAseName) = True Then 'This is true, works fine, see line '15 - 16
'=======================================================================
'== First thing I do is set DataSource for my DataGridView to nothing ==
'== and refresh, no problems here, it clears the DataGrid View as ==
'== expected. Do I need to even use this step though? ==
'=======================================================================
frmTDRG.DataGridView1.DataSource = Nothing
frmTDRG.DataGridView1.Refresh()
'=======================================================================
'== Next thing I do is reset my Database connection string to the new ==
'== MS Access Database. This appears to be working fine ==
'=======================================================================
'15
My.MySettings.Default("DBASE_ConnectionConnectionString") = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Chr(34) & strDBAseName & Chr(34) & "")
'=======================================================================
'== I then reset the DataGridView's DataSource, which I believe should==
'== be the new MS Access Database. Does this look OK? ==
'=======================================================================
frmTDRG.DataGridView1.DataSource = frmTDRG._DBASE_ConnectionDataSet.tblResults
'=======================================================================
'== I then 'fill' the DataSet with the results from the new database ==
'== or at least this is what I am trying to do. I think this may be ==
'== where it is not working, as my refresh fills the DataGridView ==
'== with the results from the original .mdb file ==
'=======================================================================
TDRG.frmTDRG.TblResultsTableAdapter.Fill(TDRG.frmTDRG._DBASE_ConnectionDataSet.tblResults)
frmTDRG.DataGridView1.Refresh()
End If
I have explained the issue as well as I can, any help that anybody can offer is much appreciated.
ADDED... 13/05/2010 14:03 GMT
I have hunted around a bit and I think the question I should really be asking is......
I wish to empty an existing DataSet (_DBASE_ConnectionDataSet) and then fill the emptied DataSet with data from my newly attached .mdb
Last edited: