ole_cmd.Connection=this.oleDbConnection1; ole_cmd.CommandText="SELECT goods AS 货物, area AS 地区, city AS 城市, refurbish_year AS 刷新年份, refurbish_month AS 刷新月份, refurbish_time AS 刷新时间,weight AS 货物质量, price AS 货物价格, shortcut AS 快捷, re AS 备注 FROM 商品"; OleDbDataAdapter ole_adp=new OleDbDataAdapter(ole_cmd); DataSet ds = new DataSet(); ole_adp.Fill(ds,"商品信息"); this.c1FlexGrid1.DataSource=ds.Tables["商品信息"]; //this.c1FlexGrid1.SetDataBinding(ds,"商品信息"); } 查询按钮的代码 private void button1_Click(object sender, System.EventArgs e) { OleDbCommand ole_cmd= new OleDbCommand();
ole_cmd.Connection=this.oleDbConnection1; ole_cmd.CommandText="SELECT goods AS 货物, area AS 地区, city AS 城市, refurbish_year AS 刷新年份, refurbish_month AS 刷新月份, refurbish_time AS 刷新时间, price AS 货物价格, shortcut AS 快捷, re AS 备注 FROM 商品 where goods='"+name.Text+"'"; OleDbDataAdapter ole_adp=new OleDbDataAdapter(ole_cmd); DataSet ds = new DataSet(); ole_adp.Fill(ds,"商品信息"); this.c1FlexGrid1.SetDataBinding(ds,"商品信息"); } 那新增,修改,删除按钮里面的代码该怎么写呢?我前面的代码怎么写才更好呢?谢谢
是不是修改过的DataGrid控件???
是的话!
查询,新增,修改,删除的
和DataGrid操作一样!
我的代码是这样写的
Form1_Load的代码
private void Form1_Load(object sender, System.EventArgs e)
{
OleDbCommand ole_cmd= new OleDbCommand();
ole_cmd.Connection=this.oleDbConnection1; ole_cmd.CommandText="SELECT goods AS 货物, area AS 地区, city AS 城市, refurbish_year AS 刷新年份, refurbish_month AS 刷新月份, refurbish_time AS 刷新时间,weight AS 货物质量, price AS 货物价格, shortcut AS 快捷, re AS 备注 FROM 商品"; OleDbDataAdapter ole_adp=new OleDbDataAdapter(ole_cmd); DataSet ds = new DataSet(); ole_adp.Fill(ds,"商品信息"); this.c1FlexGrid1.DataSource=ds.Tables["商品信息"]; //this.c1FlexGrid1.SetDataBinding(ds,"商品信息");
}
查询按钮的代码
private void button1_Click(object sender, System.EventArgs e)
{
OleDbCommand ole_cmd= new OleDbCommand();
ole_cmd.Connection=this.oleDbConnection1; ole_cmd.CommandText="SELECT goods AS 货物, area AS 地区, city AS 城市, refurbish_year AS 刷新年份, refurbish_month AS 刷新月份, refurbish_time AS 刷新时间, price AS 货物价格, shortcut AS 快捷, re AS 备注 FROM 商品 where goods='"+name.Text+"'"; OleDbDataAdapter ole_adp=new OleDbDataAdapter(ole_cmd); DataSet ds = new DataSet(); ole_adp.Fill(ds,"商品信息"); this.c1FlexGrid1.SetDataBinding(ds,"商品信息");
}
那新增,修改,删除按钮里面的代码该怎么写呢?我前面的代码怎么写才更好呢?谢谢