private void buttonExecute_Click(object sender, EventArgs e) { dataGridViewResults.DataSource = null; // Create a SQL connection instance to the NovaPACS Database string dbString = "Network Library=DBMSSOCN;user id=" + Connection.currentUserName + ";password=" + Connection.currentPassword + ";Data Source=" + Connection.currentIP + ";Integrated Security=SSPI;Initial Catalog=" + Connection.currentDbName + ";Trusted_Connection=yes;" + "connection timeout=10"; SqlConnection SQLConnect = new SqlConnection(dbString); MessageBox.Show(dbString); try { // Inject the SQL Query From The Console SqlCommand fromQConsole = new SqlCommand(richTextBoxQConsole.Text, SQLConnect); DataSet ds = new DataSet(); SQLConnect.Open(); SqlDataAdapter adapter = new SqlDataAdapter(fromQConsole); adapter.Fill(ds); try { SQLConnect.Close(); } catch { MessageBox.Show("Error: Database Connection Terminated Abnormally!", "ScriptBox", MessageBoxButtons.OK, MessageBoxIcon.Error); } // Display Query Results dataGridViewResults.DataSource = ds.Tables[0]; } catch { MessageBox.Show("Error: Cannot Open Database Connection! Check Your Connection: Please Ensure That You Have" + "Established A VPN Connection (If Applicable) Or Have Entered The Proper Authentication Credentials!", "ScriptBox", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { SQLConnect.Close(); } catch { MessageBox.Show("Error: Database Connection Terminated Abnormally!", "ScriptBox", MessageBoxButtons.OK, MessageBoxIcon.Error); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)