日期:2014-05-18 浏览次数:21292 次
private void button2_Click(object sender, EventArgs e) { CData _cData = new CData(); string sql = "update camel_thinner set thinner_name='呵呵'"; _cData.setDS(sql); } private void button3_Click(object sender, EventArgs e) { CData _cData = new CData(); string sql = "insert into camel_thinner(thinner_name) values('稀释剂')"; _cData.setDS(sql); } public class CData { private OleDbConnection conn; private OleDbDataAdapter oda = new OleDbDataAdapter(); private OleDbCommand cmd; private DataSet myds = new DataSet(); public CData() { // // TODO: 在此处添加构造函数逻辑 // conn = new OleDbConnection(Properties.Settings.Default.connectionString); } public DataSet getDS(string strSQL) { myds = new DataSet(); oda = new OleDbDataAdapter(strSQL, conn); oda.Fill(myds); return myds; } public DataSet getDS2(string strSQL, int si, int mi) { conn.Open(); myds = new DataSet(); oda = new OleDbDataAdapter(strSQL, conn); oda.Fill(myds, si, mi, "tab1"); conn.Close(); return myds; } public bool setDS(string strSQL) { conn.Open(); cmd = new OleDbCommand(strSQL, conn); cmd.ExecuteNonQuery(); conn.Close(); return true; } }