查询结果显示在另外一个窗口的datagridview里?
我在form1里加了个datagridview控件来显示数据,首先在加载的时候,显示了数据,最后想把form2里的查询f结果显示在form1里,不知道怎么办?请各位帮忙想想办法!下面是贴出来的代码:
form1的显示代码:
void WinFormLoad(object sender, System.EventArgs e)
{
string sql="select * from A";
DataBase DB=new DataBase();
DB.DBdisplay(sql,this.dataGridView1);
}
form2的主要代码:
void BtSelectClick(object sender, EventArgs e)
{
string beginy=BeginY.Text;
string beginm=BeginM.Text;
string endy=EndY.Text;
string endm=EndM.Text;
int intbeginy = Int32.Parse(beginy);
int intbeginm = Int32.Parse(beginm);
int intendy = Int32.Parse(endy);
int intendm = Int32.Parse(endm);
string sql="select * from A38II where (年="+intbeginy+" and 月>="+intbeginm+") or (年="+intendy+" and 月<="+intendm+") ";
DataBase DB=new DataBase();
gdsmistool.winForm winF=new gdsmistool.winForm();
DB.DBdisplay(sql,winF.dataGridView1);
winF.Show();
}