DBConnection.cs
1.1 KB
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
51
52
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data.SqlClient;
using Weld;
namespace Weld
{
internal class DBConnection
{
public static string DBConnstring = Properties.Settings.Default.DBConnectString;
public static SqlConnection DBConnectionOpen()
{
try
{
SqlConnection conn = new SqlConnection (DBConnstring);
conn.Open();
return conn;
}
catch (Exception ex)
{
LogExecute.WriteExceptionLog("打开数据库连接", ex);
}
return null;
}
public static SqlTransaction DBTransOpen(SqlConnection Conn)
{
try
{
if (Conn != null)
{
return Conn.BeginTransaction();
}
}
catch (Exception ex)
{
LogExecute.WriteExceptionLog("开启数据库事务", ex);
}
return null;
}
}
}