Select * statement return nothing
I am developing a code to open up a .dbf file and append data to a access database.Here is my code for opening the .dbf file.
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim constr As String = "Provider=VFPOLEDB.1;Data Source=F:\JUNO4.dbf;Persist Security Info=False;"
Dim con = New OleDbConnection(constr)
Dim da = New OleDbDataAdapter("Select UNIQUE_ID FROM JUNO4", con)
Dim ds = New DataSet()
da.Fill(ds)
'Fill data grid
dgv.DataSource = ds.Tables(0)
da = Nothing
ds = Nothing
con.Close()
con.Dispose()
End Sub
This code works fine but it only selects one field obviously.When I try to run the next code it gives me an empty dataset
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim constr As String = "Provider=VFPOLEDB.1;Data Source=F:\JUNO4.dbf;Persist Security Info=False;"
Dim con = New OleDbConnection(constr)
Dim da = New OleDbDataAdapter("Select * FROM JUNO4", con)
Dim ds = New DataSet()
da.Fill(ds)
'Fill data grid
dgv.DataSource = ds.Tables(0)
da = Nothing
ds = Nothing
con.Close()
con.Dispose()
End Sub
this code gives an empty datagrid.Please help me.I dont know whats wrong
Re: Select * statement return nothing
Is this returning one column with rows or no rows at all
Code:
Dim da = New OleDbDataAdapter("Select * FROM JUNO4", con)
Re: Select * statement return nothing
No sir it displays the datagrid but it is empty.No column names either
Re: Select * statement return nothing
Quote:
Originally Posted by
chathu1234
No sir it displays the datagrid but it is empty.No column names either
The question I asked was directed at the following statement.
Quote:
Originally Posted by
chathu1234
This code works fine but it only selects one field obviously.When I try to run the next code it gives me an empty dataset
Forget about the datagrid and instead focus on the results from the select statement as the grid is only a method to display results.
Here is what I would suggest, within Visual Studio IDE you can visually setup a database connection (menu item -> Data -> Add new data source). If I have test.dbf (a dBase III or dBase IV) in C:\Data I would set up a data connection to the folder, not the database test.dbf and set extended properties to "dBase III", in your case to the VFP which I do not have installed but I would assume this is no different than doing any other connection.
Once you have setup the connection you can traverse the databases, in this case under C:\Data. So I can see the fields for test.dbf which in my case will be two fields (a simple database).
In your case if you know say there should be five column but do not see any or only one then you have a database that may be corrupt or the provider is not capable of reading the dbf or dbc file you want to read.
I would rule out the connection since you have rec'd back data from your select statement.