title: How to Ignore some query and execute the rest of query?
body: <p>I Have 5 databases with some structures are the same and some are not, like the <code>tbl_employee_debitcredit</code> this table is not in the other database i'd like to ignore the query that is not in the database table and let the other query execute. is that possible? if yes how? reference is enough. thanks</p>
  
  <p>EDITED : this is the for loop and query im using if 1 table is missing it will stop the whole query and proceed to another database</p>
  
  <pre><code>Dim y As Integer = 0
  For x = 0 To Form1.UcAddClient1.lv_acc.Items.Count + 1
      Dim a As Integer = 0
  
      Dim constr As String = "Server=" &amp; Form1.UcAddClient1.lv_acc.Items(x).SubItems(y + 3).Text &amp; "Database=" &amp; Form1.UcAddClient1.lv_acc.Items(x).SubItems(y + 4).Text &amp; ";User id=" &amp; Form1.UcAddClient1.lv_acc.Items(x).SubItems(y + 5).Text &amp; ";password=" &amp; Form1.UcAddClient1.lv_acc.Items(x).SubItems(y + 6).Text &amp; ";Convert Zero Datetime=True;"
      'MessageBox.Show(constr)
  
      Dim conn As New MySqlConnection(constr)
  
      Try
          If conn.State = ConnectionState.Closed Then
              conn.Open()
          End If
  
          Dim sqlcmd1 As New MySqlCommand("Select * from " &amp;
              "(SELECT count(id) as Dept from departments where is_deleted = 0) as Dept, " &amp;
              "(SELECT count(payroll_group_id) as pg from payroll_groups where is_deleted = 0) as pg , " &amp;
              "(SELECT count(payroll_group_rate_id) as pgr from payroll_group_rates) as pgr, " &amp;
              "(SELECT count(id) as leaves from leaves where is_deleted = 0) as leaves, " &amp;
              "(SELECT count(id) as deminimis from de_minimis_benefits where is_deleted = 0 )as deminimis, " &amp;
              "(SELECT employee_id from tbl_employee_debitcredit where is_deleted = 0 like '%1') and is_deleted = 0) as noODC ", conn)
  
          Dim dr1 As MySqlDataReader
  
          dr1 = sqlcmd1.ExecuteReader
  
          If dr1.HasRows Then
              While dr1.Read
                  Dim newitem As New ListViewItem()
  
                  newitem.Text = Form1.UcAddClient1.lv_acc.Items(x).SubItems(y + 1).Text.ToString
                  newitem.SubItems.Add(Form1.UcAddClient1.lv_acc.Items(x).SubItems(y + 2).Text.ToString)
                  newitem.SubItems.Add(dr1.Item("Dept").ToString)
                  newitem.SubItems.Add(dr1.Item("pg").ToString)
                  newitem.SubItems.Add(dr1.Item("pgr").ToString)
                  newitem.SubItems.Add(dr1.Item("leaves").ToString)
                  newitem.SubItems.Add(dr1.Item("deminimis").ToString)
                  newitem.SubItems.Add(dr1.Item("noODC").ToString)
                  lv_client_tracker.Items.Add(newitem)
  
              End While
  
              dr1.Close()
  
          End If
  
      Catch ex As Exception
          MessageBox.Show(ex.Message)
  
      End Try
  
      End If
  
  Next
  </code></pre>