public void searchUser(string inSearch) { selectedUser = -1; lstBoxUsers.Items.Clear(); try { int userID = Convert.ToInt32(inSearch); Array.Resize(ref lstUsers, 0); SQL_Connection_Functions.searchUsers(userID); DataTable dt = new DataTable(); SQL_Connection_Functions.sqlDA.Fill(dt); createUsers(dt); } catch { Array.Resize(ref lstUsers, 0); SQL_Connection_Functions.searchUserFName(inSearch); DataTable dt = new DataTable(); SQL_Connection_Functions.sqlDA.Fill(dt); createUsers(dt); } finally { if (inSearch == "") { Array.Resize(ref lstUsers, 0); SQL_Connection_Functions.retrieveUsers(); DataTable dt = new DataTable(); SQL_Connection_Functions.sqlDA.Fill(dt); createUsers(dt); } } }
public Form1() { InitializeComponent(); try { Array.Resize(ref lstUsers, 0); SQL_Connection_Functions.retrieveUsers(); DataTable dt = new DataTable(); SQL_Connection_Functions.sqlDA.Fill(dt); createUsers(dt); } catch (Exception err) { MessageBox.Show("Could not connect due to the following error. " + err.Message); } }