C#如何写数据库连接j显示类
SqlConnection conn = new SqlConnection();conn.ConnectionString = "server=LUKE\\SQLEXPRESS;uid=sa;pwd=sa;database=luke";
conn.Open();
DataTable dt = new DataTable("resouce");
dt.Clear();
SqlDataAdapter adp = new SqlDataAdapter("select * from text1", conn);
adp.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;
这段代码是连接数据库,并显示数据的,我想把它写成类,然后调用,应该怎么做