private bool VerifyColumns()
 {
     if (VerifyServer())
     {
         if (Columns == null || Columns.Length == 0 ||
             "[" + Columns[0].ItemArray[Columns[0].Table.Columns.IndexOf("TABLE_SCHEMA")].ToString() + "].[" +
             Columns[0].ItemArray[Columns[0].Table.Columns.IndexOf("TABLE_NAME")] + "]"
             != cmbTable.Text)
         {
             try
             {
                 if (Conn.Database != cmbDatabase.Text.Trim())
                 {
                     Conn.ChangeDatabase(cmbDatabase.Text.Trim());
                 }
                 int       iDotLoc = cmbTable.Text.Trim().IndexOf('.');
                 DataTable dt      = Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
                                                              new object[] { null,
                                                                             cmbTable.Text.Trim().Substring(0, iDotLoc),
                                                                             cmbTable.Text.Trim().Substring(iDotLoc + 1, cmbTable.Text.Length - iDotLoc - 1),
                                                                             null });
                 Columns = dt.Select();
                 for (int i = 0; i < AttributesPC.Count; i++)
                 {
                     if (!Columns[0].Table.Columns.Contains(AttributesPC[i]))
                     {
                         AttributesPC.RemoveAt(i);
                         i--;
                     }
                 }
                 for (int i = 0; i < AttributesNatural.Count; i++)
                 {
                     if (!Columns[0].Table.Columns.Contains(AttributesNatural[i]))
                     {
                         AttributesNatural.RemoveAt(i);
                         i--;
                     }
                 }
                 return(true);
             }
             catch (Exception)
             {
                 return(false);
             }
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
        private void btnOptions_Click(object sender, EventArgs e)
        {
            try
            {
                if (VerifyServer())
                {
                    if (Conn.Database != cmbDatabase.Text.Trim())
                    {
                        Conn.ChangeDatabase(cmbDatabase.Text.Trim());
                    }
                    int       iDotLoc = cmbTable.Text.Trim().IndexOf('.');
                    DataTable dt      = Conn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,
                                                                 new object[] { null,
                                                                                cmbTable.Text.Trim().Substring(0, iDotLoc),
                                                                                cmbTable.Text.Trim().Substring(iDotLoc + 1, cmbTable.Text.Length - iDotLoc - 1),
                                                                                null });
                    DataRow[] dr = dt.Select();
                    Options.lbPCAttrCols.Items.Clear();
                    Options.lbNaturalAttrCols.Items.Clear();
                    for (int i = 0; i < dr.Length; i++)
                    {
                        if (cmbPID.Text.Trim() != dr[i].ItemArray[dr[i].Table.Columns.IndexOf("COLUMN_NAME")].ToString().Trim() &&
                            cmbID.Text.Trim() != dr[i].ItemArray[dr[i].Table.Columns.IndexOf("COLUMN_NAME")].ToString().Trim())
                        {
                            string col = dr[i].ItemArray[dr[i].Table.Columns.IndexOf("COLUMN_NAME")].ToString();
                            Options.lbPCAttrCols.Items.Add(col, AttributesPC.Contains(col));
                            Options.lbNaturalAttrCols.Items.Add(col, AttributesNatural.Contains(col));
                        }
                    }

                    Options.tabControl1.Enabled = true;
                }
            }
            catch (Exception)
            {
                Options.tabControl1.Enabled = false;
            }
            Options.ShowDialog();
        }