OleDbSqlHelper使用例子
时间:2011-03-09 来源:五年
private void button1_Click(object sender, EventArgs e)
{
// this.bindingSource1.DataSource = Bmk.FindAll();
this.bindingSource1.DataSource =
OleDbHelper.ExecuteDataTable(Conn.AccessConnection,
@"select * from bmk order by bmxh ");
this.dataGridView1.DataSource = bindingSource1;
this.label1.Text = Bmk.GetCount(Condition.Empty).ToString();
// MessageBox.Show(Bmk.FindById(1).xm);
}
private void button2_Click(object sender, EventArgs e)
{
int i = 0;
foreach (var bmk in Bmk.FindAll())
{
if (!string.IsNullOrWhiteSpace(bmk.tcxm))
{
OleDbParameter[] param = new OleDbParameter[2];
param[0] = OleDbHelper.CreateInParam("tcxm",OleDbType.Char,2, bmk.tcxm);
param[1] = OleDbHelper.CreateInParam("bmxh", OleDbType.Char, 9, bmk.bmxh);
string strSql = @"update bmk set tcxm = ? where bmxh = ? ";
OleDbHelper.ExcuteSQL(Conn.VfpConnection, strSql, param);
//string strSql = string.Format("update bmk set tcxm = '{0}' where bmxh = '{1}' ",
// bmk.tcxm, bmk.bmxh);
//OleDbHelper.ExcuteSQL(Conn.VfpConnection, strSql);
}
i++;
//if (i > 10)
// break;
}
MessageBox.Show("OK!");
}