private void cmbTables_SelectedIndexChanged(object sender, EventArgs e) { int noOfRows = 10; if (!string.IsNullOrWhiteSpace(txtRecordCount.Text)) { noOfRows = Convert.ToInt32(txtRecordCount.Text, CultureInfo.InvariantCulture); } try { dgData.DataSource = null; dgData.DataSource = DBHandler.GetTableData(cmbDatabase.Text, cmbTables.Text, noOfRows); } catch (SqlException exc) { using (StreamWriter wrtr = new StreamWriter("Error.log", true)) { wrtr.WriteLine("Table Change" + Environment.NewLine + DateTime.Now.ToLongDateString() + Environment.NewLine + DateTime.Now.ToLongTimeString() + Environment.NewLine); wrtr.WriteLine(exc.Message); wrtr.WriteLine(exc.StackTrace); wrtr.WriteLine(new String('_', 80)); wrtr.Flush(); } MessageBox.Show("Exception occured : " + Environment.NewLine + "\t" + exc.Message + Environment.NewLine + Environment.NewLine + "Detailed exception log has been generated as [Error.Log]. Please post the content on the MSDN DB Invader page or techphernalia.com to get it resolved.", "DB Explorer : from techPhernalia.com : by Durgesh Chaudhary"); } }