KetNoi-Coso
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace Qlxe
{
class KetNoi
{
public static SqlConnection cn;
public static void MoKetNoi()
{
string st = string.Format(@"Data Source=.\SQLEXPRESS;Initial Catalog=QlyXe;User ID=sa;Password=123");
cn = new SqlConnection(st);
cn.Open();
}
public static SqlCommandBuilder cmb;
public static SqlDataAdapter da;
public static DataTable GetBang(string TenBang)
{
//MoKetNoi();
string st = string.Format("select * from " + TenBang);
SqlCommand cmd = new SqlCommand(st,cn);
da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
cmb = new SqlCommandBuilder(da);
da.Fill(ds, TenBang);
return ds.Tables[0];
}
}
}
Bạn đang đọc truyện trên: AzTruyen.Top