コード例 #1
0
        protected void btnCheckSyntax_Click(object sender, EventArgs e)
        {
            Key1.Text = "Parsed SQL.";
            string inputStr = TextBox1.Text;                                                            // set the input string equal to the input in Textbox1

            if (inputStr.Length == 0)
            {
                Key1.Text = "No SQL provided.";                                                      // if the user enters no input, then output to error box, letting user know.
            }
            else
            {
                inputStr = ScrubSQLstring(inputStr);                                                    // pass inputStr to Scrub function, set to inputStr
                char[] delimiters = new char[] { ' ' };                                                 // set delimiter characters
             // pass scrubbed input, and element count to Build Token array, located in the utilities.cs file.
                businesslogic.blSQLapp checker = new businesslogic.blSQLapp();                          // create instance of our SQLutilities class, call it "checker"

                string[] tokenArray = checker.BuildTokenArray(inputStr);                                // pass our instance "checker " the input string IOT have it build an array consisting of the components(tokens) of the SQL input.
             // checker.CheckSQLsyntax(tokenArray);                                                     // pass the array of tokens to the CheckSQLsyntax() method
             //   if (checker.errorFound)
             //   {                                                                // check to see if errorFound was tripped in our instances.
             //       Errors1.Text = checker.getError();                                                  // if they were, then set errors to text box <<<<<<<<<<<<<<<<<<<<<<DEBUGGING STEP>>>>>>>>>>>>>>>>>>>
             //   }
                List<string> lst = tokenArray.OfType<string>().ToList();                                // take the array that we got back and turn it into a list

                DataTable returneddl = checker.GetSQLresult(inputStr, ConnectionString);

                returnedDL.DataSource = returneddl;
                returnedDL.DataBind();

                GridView1.DataSource = lst;                                                             // set the datasource
                GridView1.DataBind();                                                                   // bind it
            }
        }
コード例 #2
0
        private void PopulateGridView()
        {
            businesslogic.blSQLapp lister = new businesslogic.blSQLapp();                          // create instance of our SQLutilities class, call it "lister".
            DataTable dtRace = lister.GetSQLresult(tbQuery.Text, ConnectionString, 1);

            DataView dvRace = dtRace.DefaultView;
            dvRace.Sort = Session["SortExpression"].ToString() + " " + Session["SortDir"].ToString();

            gvRaceList.DataSource = dvRace;
            gvRaceList.DataBind();
        }