Changed the requirements of the integrity checking form to need a connection string. The login form willl now attempt to use the connection string setting but failing that it will use the server name in the combo box. The main form will use the app's connection string setting.
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
@@ -19,18 +13,18 @@ namespace AdvertsingProfitControl
|
||||
private readonly Dictionary<int, DatabaseTable.RepairLevel> _errorsDictionary = new Dictionary<int, DatabaseTable.RepairLevel>();
|
||||
private readonly List<DatabaseDbCcResult> _databaseDbCcResults = new List<DatabaseDbCcResult>();
|
||||
|
||||
public FrmIntegrityCheck()
|
||||
public FrmIntegrityCheck(string connectionString)
|
||||
{
|
||||
InitializeComponent();
|
||||
RunDbCheck();
|
||||
RunDbCheck(connectionString);
|
||||
}
|
||||
|
||||
private void RunDbCheck()
|
||||
private void RunDbCheck(string connectionString)
|
||||
{
|
||||
var reportsTable = new DataTable();
|
||||
try
|
||||
{
|
||||
using (var connection = new SqlConnection(Properties.Settings.Default.ConnectionString))
|
||||
using (var connection = new SqlConnection(connectionString))
|
||||
{
|
||||
var query = @"IF NOT OBJECT_ID('tempdb..#CheckDB') IS NULL
|
||||
DROP TABLE #CheckDB;
|
||||
|
||||
@@ -98,7 +98,15 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void checkIntegrityToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new FrmIntegrityCheck();
|
||||
//Check to see if the properties of the program have a last known good connection string.
|
||||
var connectionString = Properties.Settings.Default.ConnectionString;
|
||||
if(connectionString == string.Empty)
|
||||
{
|
||||
//If the connection string isn't set then attempt to use the connection string
|
||||
//that is in this form's combo box.
|
||||
connectionString = "Data Source=" + serverNameComboBox.Text + ";Initial Catalog=AdvertisingProfitControl;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework";
|
||||
}
|
||||
var form = new FrmIntegrityCheck(connectionString);
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1136,7 +1136,9 @@ namespace AdvertsingProfitControl
|
||||
|
||||
private void testToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var t = new FrmIntegrityCheck();
|
||||
//Considering we're at the main form, it can be a safe bet that this program's connection string
|
||||
//property is set correctly, so simply use that for the Integrity form.
|
||||
var t = new FrmIntegrityCheck(Properties.Settings.Default.ConnectionString);
|
||||
t.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user