01.
public
class
DBClass
02.
{
03.
private
string
STR_CONNECTION =
"Server=HOADNA-PC\\SQLEXPRESS;Uid=sa;PASSWORD=123;database=aa;Max Pool Size=400;Connect Timeout=600;"
;
04.
private
SqlConnection DBConnection;
05.
private
SqlCommand DBCommand;
06.
private
SqlDataAdapter DBAdapter;
07.
private
SqlTransaction Trans =
default
(SqlTransaction);
08.
09.
public
DBClass()
10.
{
11.
DBConnection =
new
SqlConnection(STR_CONNECTION);
12.
DBConnection.Open();
13.
Trans = DBConnection.BeginTransaction(IsolationLevel.ReadCommitted);
14.
15.
DBCommand =
new
SqlCommand();
16.
DBCommand.Connection = DBConnection;
17.
DBCommand.Transaction = Trans;
18.
DBAdapter =
new
SqlDataAdapter();
19.
20.
}
21.
22.
public
DataSet Query(
string
strSQL)
23.
{
24.
DataSet DS =
new
DataSet();
25.
try
26.
{
27.
DBCommand.CommandText = strSQL;
28.
DBAdapter.SelectCommand = DBCommand;
29.
DBAdapter.Fill(DS);
30.
Trans.Commit();
31.
}
32.
catch
(Exception Ex)
33.
{
34.
Trans.Rollback();
35.
}
36.
finally
37.
{
38.
DBConnection.Close();
39.
}
40.
return
DS;
41.
}
42.
}