We have a need to grab the contents in one MySql Database and then check to see if each line is in a separate MySQL database table (Different schema). Then display results to include number of matched records.
I am building the 1st list and then using a for loop to search the 2nd table for records with the same email address. This is slow - 1 second per loop, is there a better or faster way to do this?
Private Sub ConnectButton_Click(sender As Object, e As EventArgs) Handles ConnectButton.Click
Dim SQLStr As String = "select t.id,t.title,t.fname,t.lname,t.transaction_ref,t.status,email from membership as t where (t.status = 2) and (t2.cost > 0)"
SQLDt.Reset()
Dim Dta As New MySqlDataAdapter(SQLStr, SQLConn)
Dta.Fill(SQLDt)
DataGridView1.DataSource = SQLDt
SQLDt.Columns.Add("Found", GetType(Integer))
Dim row As DataRow
Dim column As DataColumn
TextBox2.Text = SQLDt.Rows.Count
TextBox2.Refresh()
For Each row In SQLDt.Rows
Dim emailstr As String = row.Item("email")
Dim rowint As Integer = SQLDt.Rows.IndexOf(row)
Dim InternalCRMSQLStr As String = "select * from membership where (email = '" + emailstr + "') AND membershipid IS NOT NULL "
InternalCRMSQLDt = New DataTable
Dim InternalCRMDta As New MySqlDataAdapter(InternalCRMSQLStr, InternalCRMSQLConn)
InternalCRMDta.Fill(InternalCRMSQLDt)
If InternalCRMSQLDt.Rows.Count > 0 Then
SQLDt.Rows(rowint)("Found") = InternalCRMSQLDt.Rows.Count
Else
SQLDt.Rows(rowint)("Found") = 0
End If
TextBox1.Text = rowint
TextBox1.Refresh()
Next
End Sub