110,500
社区成员
发帖
与我相关
我的任务
分享
private void btnSearch_Click(object sender, EventArgs e)
{
if (validateInput())
{
string sql=string.Format("select c.invCode,i.cInvName,i.cInvStd,i.cComUnitName,c.BaseQtyN,c.BaseQtyD,i.cDefWareHouse,i.cWhName,i.cInvCname,c.loc,i.iInvNcost from bom_child as c inner join Inventorys as i on c.invCode=i.cInvCode where bomid=(select bomid from bom_parents where invCode='{0}' and version='{1}')",txtParentCode.Text,cboBomVersion.Text);
try
{
dataAdapter = new SqlDataAdapter(sql, DBHelp.connection);
dataAdapter.Fill(dataSet, "child");
dgvChild.DataSource = dataSet.Tables["child"];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
DBHelp.connection.Close();
}
}
}
datagridview.DataSource=null;
dgvChild.DataSource = dataSet.Tables["child"];
Or
datagridview.Rows.Clear();
dgvChild.DataSource = dataSet.Tables["child"];