'Problem with file chooser in postman in Manjaro
Solution 1:[1]
Regarding your question, you can check for each statement by splitting on ; and then checking for each statement:
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<string> myStatementTypes=new List<string>();
string mySqlQueries=@"SELECT * FROM country;
CREATE VIEW getCountries AS SELECT * FROM country;
SELECT * FROM city;";
var tokenizedQuery=mySqlQueries.Split(";");
foreach(var item in tokenizedQuery)
{
//Console.WriteLine(item.Trim());
if(item.Trim().StartsWith("select",StringComparison.InvariantCultureIgnoreCase))
{
myStatementTypes.Add("Select Statement");
}
else if(item.Trim().StartsWith("create",StringComparison.InvariantCultureIgnoreCase))
{
myStatementTypes.Add("Create Statement");
}
}
foreach(var result in myStatementTypes)
{
Console.WriteLine(result);
}
}
}
Working example: https://dotnetfiddle.net/x86b8l
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Rahul Sharma |

