예제 #1
0
 private void tabSqlScripts_Click(object sender, EventArgs e)
 {
     pnlInsertControls.Controls.Clear();
     chkListBoxColumns.Items.Clear();
     txtoutput.BringToFront();
     GridSelect.SendToBack();
     txtoutput.Text = "";
 }
예제 #2
0
        //In this function we will check for the Select query type as user entered or user selected columns to display.

        private void buildSelectScript()
        {
            DataTable dt = new DataTable();

            Cursor.Current = Cursors.WaitCursor;

            if (chkWriteSelectQuery.Checked == true)
            {
                if (txtSelectQuery.Text.Trim() == "")
                {
                    MessageBox.Show("Enter Select Query");
                    txtSelectQuery.Focus();
                    return;
                }

                string sqlSelectQuery = txtSelectQuery.Text.ToLower().Trim();
                if (sqlSelectQuery.Contains("select") == true)
                {
                    if (!objSQL.sqlInjectionCheck(sqlSelectQuery))
                    {
                        return;
                    }
                    dt = objSQL.selectRecordsfromTableQuery(txtDBNAME.Text.Trim(), txtSelectQuery.Text.Trim());
                }
            }
            else
            {
                if (cboTable.Items.Count <= 0)
                {
                    MessageBox.Show("Select valid Table to select Column");
                    return;
                }
                if (cboTable.SelectedItem.ToString() == "")
                {
                    MessageBox.Show("Select valid Table to select Column");
                    return;
                }

                bool isAllcolumn = false;
                if (chkAllColumns.Checked == true)
                {
                    isAllcolumn = true;
                }
                else
                {
                    if (chkListBoxColumns.CheckedItems.Count <= 0)
                    {
                        MessageBox.Show("Select Columns ");
                        return;
                    }
                }
                GridSelect.DataSource = null;
                dt = objSQL.selectRecordsfromTableQuery(isAllcolumn, chkListBoxColumns, txtDBNAME.Text.Trim(), cboTable.SelectedItem.ToString());
            }

            if (dt.Rows.Count > 0)
            {
                txtoutput.SendToBack();
                GridSelect.BringToFront();
                GridSelect.DataSource = dt;
            }
            else
            {
                txtoutput.BringToFront();
                GridSelect.SendToBack();
                txtoutput.ForeColor = Color.DarkRed;
                txtoutput.Text      = "Sorry No records to Display";
                MessageBox.Show("Sorry No records to Display");
            }
            Cursor.Current = Cursors.Default;
        }