** DO NOT USE THIS CODE IN PRODUCTION MODE, THIS CODE IS ONLY FOR TEST PURPOSES! **
EasySQL is a C# Wrapper that allow you to manage MySQL easily.
- Easy to understand.
- Fast and structured query result.
- Easy to connect and dispose
- MySQL NuGet package.
Compile this source-code and add as reference into your project.
Here is a simple introduction to how to use EasySQL:
Put our using in your project typing:
using EasySQL.SQL;
SQL myConnection = new SQL("myUsername", "myPassword", "myDatabase", "127.0.0.1");
var conn = myConnection.CreateConnection();
if(conn)
{
//You're connected
}
List<string> keys = { "name", "number" };
List<object> values = { "Washington", 17 };
bool insertValues = myConnection.Insert("myTable", keys, values);
if(insertValues)
{
//Data was inserted
}
List<string> keys = { "number" };
List<object> values = { 96 };
bool updateValues = myConnection.Update("myTable", keys, values, string.Format("name='{0}'", "Washington"));
if(updateValues)
{
//Data was updated
}
bool deleteValues = myConnection.Delete("myTable", string.Format("name='{0}'", "Washington"));
if(deleteValues)
{
//Data was deleted
}
var Result = myConnection.Get("*", "myTable", "number=96");
if(Result.Count != 0)
{
//has results
foreach(var row in Result)
{
var nameColumn = row.GetValue(0).ToString();
var countryColumn = row.GetValue(1).ToString();
Console.WriteLine(string.Format("Name: {0} Number: {1}", nameColumn, countryColumn));
}
}
At the end of script remember to use the Dispose function to finish the connection!
myConnection.Dispose();
- Make it faster
- Create best way to use conditional
- Best security with conditionals, to block possible SQL Injection
Best regards, Washington