string from = "from", select = "select", where = "where", groupBy = "group by", orderBy = "order by"; string sql = "SELECT X, Y, Z FROM Table WHERE X=9 AND Y =10 AND Z BETWEEN 1 AND 6 ORDER BY X GROUP BY Z"; ; string lSql = sql.ToLower(); int fromIndex = lSql.IndexOf(from) + from.Length; int selectIndex = lSql.IndexOf(select) + select.Length; int whereIndex = lSql.IndexOf(where) + where.Length; int groupByIndex = lSql.IndexOf(groupBy) + groupBy.Length; int orderByIndex = lSql.IndexOf(orderBy) + orderBy.Length; string colummExp = sql.Substring(selectIndex, fromIndex - from.Length - selectIndex).Trim(); string fromExp = sql.Substring(fromIndex, (whereIndex > 0 ? (whereIndex - where.Length) : lSql.Length) - fromIndex).Trim(); int s = groupByIndex > orderByIndex ? orderByIndex : groupByIndex; int l = groupByIndex > orderByIndex ? orderBy.Length : groupBy.Length; string whereExp = sql.Substring(whereIndex, (s > 0 ? s - l : lSql.Length) - whereIndex).Trim();
Tuesday, August 17, 2010
How to extract information from SQL query using C#
Subscribe to:
Post Comments (Atom)
Azure Storage Account Types
Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...
-
Why we need asynchronous tasks? Execute a time consuming operations in parallel to the CLR thread which execute the request If you have ...
-
Demo: I was thinking a way to show images before actually uploading them to server. I would say to preview images using javascript. Obv...
No comments:
Post a Comment