-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDBConnection.cs
38 lines (35 loc) · 975 Bytes
/
DBConnection.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
namespace pos_and_inventory_csharp
{
internal class DBConnection
{
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
SqlDataReader dr;
public string MyConnection()
{
string con = @"Data Source=ICM-LUCAS;Initial Catalog=POS_DEMO_DB;Integrated Security=True";
return con;
}
public double GetVal()
{
double vat=0;
cn.ConnectionString = MyConnection();
cn.Open();
cm = new SqlCommand("select * from tblvat ", cn);
dr = cm.ExecuteReader();
while (dr.Read())
{
vat = double.Parse(dr["vat"].ToString());
}
dr.Close();
cn.Close();
return vat;
}
}
}