|
|
|
@ -76,6 +76,7 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
cmd.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
connection.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -87,12 +88,19 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
public int ExecuteNonResult(string query, DbParameter[] par)
|
|
|
|
|
{
|
|
|
|
|
using (DbConnection connection = _factory.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var cmd = CreateCommand(connection, query, par, Timeout))
|
|
|
|
|
{
|
|
|
|
|
return cmd.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
connection.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public T Insert<T>(string insert_query, SqlParameter[] par)
|
|
|
|
@ -108,6 +116,7 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
connection.Close();
|
|
|
|
|
connection.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -148,6 +157,7 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
da.Fill(ds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
connection.Close();
|
|
|
|
|
}
|
|
|
|
|
return ds;
|
|
|
|
|
}
|
|
|
|
@ -164,6 +174,7 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
da.Fill(ds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
connection.Close();
|
|
|
|
|
}
|
|
|
|
|
return ds;
|
|
|
|
|
}
|
|
|
|
@ -173,23 +184,37 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
public object ExecuteScalar(string query)
|
|
|
|
|
{
|
|
|
|
|
using (var connection = _factory.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var cmd = CreateCommand(connection, query, null, Timeout))
|
|
|
|
|
{
|
|
|
|
|
return cmd.ExecuteScalar();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
connection.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object ExecuteScalar(string query, DbParameter[] par)
|
|
|
|
|
{
|
|
|
|
|
using (var connection = _factory.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var cmd = CreateCommand(connection, query, par, Timeout))
|
|
|
|
|
{
|
|
|
|
|
return cmd.ExecuteScalar();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
connection.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -197,6 +222,8 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
public int ExecProcedure(string name)
|
|
|
|
|
{
|
|
|
|
|
using (var connection = _factory.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var command = new SqlCommand(name, connection)
|
|
|
|
|
{
|
|
|
|
@ -207,6 +234,11 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
return command.ExecuteNonQuery();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
connection.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -281,7 +313,7 @@ namespace ZeroLevel.SqlServer
|
|
|
|
|
return new SqlParameter[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static SqlCommand CreateCommand(DbConnection connection, string query, DbParameter[] parameters, int timeout)
|
|
|
|
|
public static SqlCommand CreateCommand(DbConnection connection, string query, DbParameter[] parameters, int timeout)
|
|
|
|
|
{
|
|
|
|
|
var command = connection.CreateCommand();
|
|
|
|
|
command.CommandText = query;
|
|
|
|
|