/// <summary> /// LoadTableList() - Load the list of Table Names /// </summary> /// <param name="tdList">(Output) List to be loaded</param> /// <returns>Initial Select Item (Caption)</returns> private string LoadTableList(out List <TableData> tdList) { string defaultSelection = "<-- No Tables Available -->"; tdList = new List <TableData>(); try { if (txtConnStr.Text != "") { // Load Columns fpr requested Table TableDataDl dl = new TableDataDl(); tdList = dl.ListTableData(txtConnStr.Text); if (tdList.Count > 0) { defaultSelection = "<--Select-->"; } } } catch (Exception) { defaultSelection = "<-- DB Connection Issue -->"; } return(defaultSelection); }
/// <summary> /// ValidateInput() - Validate the Connection String details. /// </summary> /// <returns>String containing the formatted output. Blank if no errors.</returns> private string ValidateInput() { List <string> errorMsg = new List <string>(); StringBuilder sb = new StringBuilder(); if (txtServer.Text == "") { errorMsg.Add("Please enter a Server Name"); } if (txtInitialCatalog.Text == "") { errorMsg.Add("Please enter an Initial Catalog"); } if (radServer.IsChecked == true) { if (txtUserId.Text == "") { errorMsg.Add("Please enter a User Id"); } if (txtPassword.Password == "") { errorMsg.Add("Please enter a Password"); } } if (errorMsg.Count == 0) { Mouse.OverrideCursor = Cursors.Wait; SetProperties(); TableDataDl csTest = new TableDataDl(); if (!csTest.VerifyConnectionString(GetConnectionString())) { errorMsg.Add("Connection String could not connect to DB"); } Mouse.OverrideCursor = Cursors.Arrow; } if (errorMsg.Count > 0) { sb.AppendLine("Validation errors occurred:"); errorMsg.ForEach(em => sb.AppendLine("- " + em)); } return(sb.ToString()); }