Hi fellow members of Daniweb.
I've been working on project for the past few days now, and have come across a bump, that i am unable to pass.
The project, when finished, will do the following:
- Select DBF file from computer location (Default C:)
- Import the database file into a DataGridView
- Export the Datagridview into a file type of choice (For the meantime it will be an .XSLX file)
Now i know there are many software out there that do this already, however i require this one for unique capabilities within my workplace.
Currently, i can open a OpenFileDialog, select the file i need, and import it. However the Datagridview stays empty. and i recieve no error.
Im very interested to see why/how this happens - and hoping somebody can point out where i have gone wrong.
The following code executes when the file has been chosen and the user hits 'btnNext':
If txtFileName.Text = "" Then
MsgBox("Error! You must choose a file!")
Return
End If
dbfiledir = ofdFileSearch.FileName.ToString()
dbfilename = ofdFileSearch.SafeFileName.ToString().Split(".")(0)
dbfilefolder = dbfiledir.Substring(0, 3)
Me.Hide()
MsgBox(dbfilefolder) 'The 3 messagebox's are a part of my testing.
MsgBox(dbfilename)
MsgBox(dbfiledir)
frmStepTwo.visible = True
Now when frmStepTwo appears the following gets executed:
Dim cnn As New System.Data.OleDb.OleDbConnection
Dim da As New System.Data.OleDb.OleDbDataAdapter
Dim theDataSet As New DataSet
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbfilefolder & ";Extended Properties=dBASE IV;User ID=Admin;Password=;"
Try
cnn.Open()
da.SelectCommand = New System.Data.OleDb.OleDbCommand("select * from [" & dbfilename & "]", cnn)
da.Fill(theDataSet)
DataGridView1.DataSource = theDataSet
DataGridView1.Refresh()
Catch ex As Exception
MsgBox("Error while connecting to databse." & vbNewLine & ex.Message & vbNewLine & ex.ToString)
End Try
This is all well and good, however no results in the database. I did some research to see if it had anything to do with the connectionstring. And i beleive this is the correct statement.
Any help with this issue, is greatly appreciated.
Regards