1
This commit is contained in:
@@ -422,6 +422,40 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行SQL语句
|
||||
/// </summary>
|
||||
/// <param name="sql">sql语句</param>
|
||||
public static bool ExecuteSql(string sql)
|
||||
{
|
||||
bool result = false;
|
||||
using (SqlConnection Connection = new SqlConnection(connectionString))
|
||||
{
|
||||
try
|
||||
{
|
||||
result = true;
|
||||
Connection.Open();
|
||||
SqlCommand command = new SqlCommand(sql, Connection)
|
||||
{
|
||||
CommandTimeout = 0,
|
||||
CommandType = CommandType.Text
|
||||
};
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result = false;
|
||||
ErrLogInfo.WriteLog($"【执行SQL语句报错】{sql};【错误信息】{ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Connection.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Creates a DataSet by running the stored procedure and placing the results
|
||||
|
||||
Reference in New Issue
Block a user