-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLUtility.cs
More file actions
27 lines (25 loc) · 740 Bytes
/
SQLUtility.cs
File metadata and controls
27 lines (25 loc) · 740 Bytes
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
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
namespace CPUFramework
{
public class SQLUtility
{
public static string ConnectionString = "";
public static DataTable GetDataTable(string sqlstatement) //- take a SQL statement and return a DataTable
{
Debug.Print(sqlstatement);
DataTable dt = new();
SqlConnection conn = new();
conn.ConnectionString = ConnectionString;
conn.Open();
var cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = sqlstatement;
var dr = cmd.ExecuteReader();
dt.Load(dr);
return dt;
}
}
}
//note