Make method to generate SQL query (Insert, Updated, Select, and Delete) but read about SQL injection
Is it important to prevent injection while my application is run on local PC and without share database and user can find database file and open it.
Why need to prevent my Query from injection?
class Cls_SQLGen
{
public static void SQLInsert(string TableName, string[,] ColNameValues)
{
string Query = "Insert into " + TableName + " ( ";
#region Build query for insert
for (int i = 0; i < ColNameValues.GetLength(0); i++)
{
string ColNames;
if (i == ColNameValues.GetLength(0) - 1)
{
ColNames = ColNameValues[i, 0] + " ) ";
}
else
{
ColNames = ColNameValues[i, 0] + ", ";
}
Query += ColNames;
}
Query += "Values (";
for (int i = 0; i < ColNameValues.GetLength(0); i++)
{
string ParamName;
if (i == ColNameValues.GetLength(0) - 1)
{
ParamName = " @" + ColNameValues[i, 0] + ")";
}
else
{
ParamName = " @" + ColNameValues[i, 0] + ",";
}
Query += ParamName;
}
#endregion
DAL.SQLiteAccessLayes.ExcuteCommand(Query, ColNameValues);
}
}