I would like to populate listbox with only items from database B (1st column) by comparing those items split values (.Split(":")(0)
) with values from database A (column 2). If split value from database A exist in database B then ignore that item, else add that item in listbox.
I know that I have to connect to both databases but I don't know how to create a loop that would check if split value from one database exists in another and put missing (undivided values) in listbox?
These are database connections
'DATABASE B
Dim cn As OleDb.OleDbConnection
Dim strSQL As String
cn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=w:\Sifarnik.MDB")
strSQL = "SELECT A1A FROM TILSIF"
cn.Open()
'DATABASE A
Dim cn2 As OleDb.OleDbConnection
Dim strSQL2 As String
cn2 = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\;Extended Properties=dBASE IV;")
strSQL2 = "SELECT BUSS From [DD Pa]"
cn2.Open()
Thanks.
EDIT : I populated listbox with only split values now all I need is to check every item in listbox if that item exist in another database and if does remove it. Once again I need halp with loop in code below.
Dim cn As OleDb.OleDbConnection
Dim cmd As OleDb.OleDbCommand
Dim odr As OleDb.OleDbDataReader
Dim strSQL As String
cn = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\;Extended Properties=dBASE IV;")
strSQL = "SELECT POSLOVNIPA From [Ap 1a]"
cn.Open()
cmd = New OleDb.OleDbCommand(strSQL, cn)
odr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Do While odr.Read
ListBox2.Items.Add(odr.GetValue(0).Split(":")(0))
Loop
EDIT 2 : Now I have two listboxes, one for each database. My question would be how to edit loop to include removal pf items that exist in listbox3 and repopulate listbox 2 with complete value without split?
Do While odr.Read
ListBox2.Items.Add(odr.GetValue(0).Split(":")(0))
Loop