Getting column data from different tables in ms access using oledb

  • Thread starter Thread starter ai1231
  • Start date Start date
A

ai1231

Guest
Hi!

I am trying to get data for different columns in different tables but this code give me an error

I tried using union select too but I don't know how to get the result devided with executereader

SELECT Pas_ID FROM ABR UNION SELECT Nr_dok FROM C ORDER BY Pas_ID;
But I get all results mixed together


What I want is get on listbox1 column1,column2 of table1 and on listbox2 column1,column2 of table2





Dim cmdString As String = "SELECT Pas_ID FROM ABR;SELECT Nr_dok FROM C;"
Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\test.mdb;Jet OLEDB:Database Password=;Mode=Share Deny Read|Share Deny Write;"
Dim myConnection As OleDbConnection = New OleDbConnection(connString)
myConnection.Open()
Dim TheCommand As OleDbCommand = New OleDbCommand(cmdString, myConnection) With {
.CommandType = CommandType.Text
}
Dim TheDataReader As OleDbDataReader = TheCommand.ExecuteReader()
While TheDataReader.Read()
ListBox1.Items.Add(TheDataReader.GetString(0))
End While
If TheDataReader.NextResult() Then
While TheDataReader.Read()
ListBox2.Items.Add(TheDataReader.GetString(0))
End While
End If

Continue reading...
 

Similar threads

V
Replies
0
Views
98
VB Novice Hendri
V
V
Replies
0
Views
114
VB Novice Hendri
V
V
Replies
0
Views
122
VB Novice Hendri
V
S
Replies
0
Views
70
Stavros Papadakis
S
Back
Top