-
Notifications
You must be signed in to change notification settings - Fork 0
/
MySqlExtension.cs
50 lines (44 loc) · 1.43 KB
/
MySqlExtension.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//Copyright 2020 REDSHADOWTH(Phumiphat Joreonyonwhatthana) under MIT Licence.
//MIT Licence https://opensource.org/licenses/MIT
using System;
using Excel_Data_Import__MySql_.Data;
using MySql.Data.MySqlClient;
namespace Excel_Data_Import__MySql_.MySql
{
public struct IMySqlCommand
{
public string Command;
}
public static class MySqlExtension
{
private static string exception = "";
private static MySqlConnection connection = new MySqlConnection(DataStore._config.ConnectionString);
public static bool Execute(this IMySqlCommand commandData)
{
try
{
connection.Open();
char singleQuote = (char)39;
string insertCommand = commandData.Command;
MySqlCommand cmd = new MySqlCommand(insertCommand, connection);
cmd.CommandTimeout = 280000;
cmd.ExecuteNonQuery();
connection.Close();
return true;
}catch(Exception ex)
{
exception = ex.ToString();
return false;
}
}
public static string GetException(this IMySqlCommand data)
{
return exception;
}
// not use.
//private static MySqlConnection GetConnection()
//{
// return new MySqlConnection(DataStore._config.ConnectionString);
//}
}
}