Parsing SQL Query .


hi guys

i working sl4 , problem bit different .

i parsing sql queries , creating .

i filtering on basis of , order , and operators

things works fine , if there string filter , in operatos

and in string parameters if there string containing , order or , word

is there better way parse queries ?

regards.

 

 

 

you can use following code:

string query = "select * table table.field1='where' , table.field2='and'where";    bool inquotes = false;  (int = 0; < query.length; i++)  {      if (query.substring(i, 1) == "'")          inquotes = !inquotes;        if (i + 5 <= query.length)      {          if (query.substring(i, 5).toupper() == "where" && !inquotes)          {              query = query.substring(0, i) + "__where__" + query.substring(i + 5);              += 9;          }                          }      if (i + 3 <= query.length)      {          if (query.substring(i, 3).toupper() == "and" && !inquotes)          {              query = query.substring(0, i) + "__and__" + query.substring(i + 3);              += 7;          }      }  }

regards,
gautier



Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Reindexing

Users List

List of charts