private void button3_Click(object sender, EventArgs e) { bool check = false; string com = "COM"; int port = 1; com = "COM" + port.ToString(); while (!check) { try { SMSCOMMS SMSEngine = new SMSCOMMS(com); check = SMSEngine.Open1(); if (check == false) { port = port + 1; com = "COM" + port.ToString(); } else { check = true; label3.Text = "Connected to PORT : " + com; } } catch { } } /* * dbConn.Open(); * dataGrid.DataSource = @"Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Users\Taimoor\Desktop\Workshop\Client servercomunication\Client servercomunication\serversocket\serversocket\RFID_TRACKER.mdb"; * dataGrid.Refresh(); * this.dataGrid.Refresh(); * DataSet ds = new DataSet(); * DataTable dt = new DataTable(); * ds.Tables.Add(dt); * OleDbDataAdapter dd = new OleDbDataAdapter(); * dd = new OleDbDataAdapter("Select * From LOG", dbConn); * dd.Fill(dt); * dataGrid.DataSource = dt.DefaultView; * dbConn.Close(); */ }