Can I do two select statement in different table in one query in OleDbCommand? I'm reading a .dbf files and I want to fill my dataset on it.
SELECT * FROM BILLHEAD SELECT * FROM BILLDETA
I'm getting an error
Syntax error in FROM clause.
Here's my code :
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
oLoadDb("SELECT * FROM BILLHEAD " & vbCrLf & " SELECT * FROM BILLDETA")
DataGridView1.DataSource = oDs.Tables(0).DefaultView
DataGridView2.DataSource = oDs.Tables(1).DefaultView
End Sub
Dim oDs As DataSet
Private Function oLoadDb(ByRef dbf_file As String)
Try
Dim FilePath As String = "D:\DBF"
Dim SQLstr As String = dbf_file
Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath & _
" ;Extended Properties=dBASE IV;User ID=Admin;Password="
Try
Dim DBFConn As New OleDbConnection(ConnString)
DBFConn.Open()
Dim DBFCommand As OleDbCommand = New OleDbCommand(SQLstr, DBFConn)
Dim DBFDataReader As OleDbDataReader = DBFCommand.ExecuteReader(CommandBehavior.SequentialAccess)
Dim daData As OleDbDataAdapter
daData = New OleDbDataAdapter(SQLstr, DBFConn)
oDs = New DataSet
daData.Fill(oDs)
DBFConn.Close()
Catch ex As Exception
Debug.WriteLine(ex.Message.ToString)
End Try
Catch ex As Exception
End Try
End Function
If both tables having the same data structure you can do
to get all data from the tables