Dim cmd As New SQLCommand
cmd.C
Dim sg As String = "select a.提货合同号,a.客户名称,a.提货运费,b.目的城市,b.车牌号,b.司机姓名,b.提货日期 from {提货合同明细} a left join {提货合同单据} b on a.提货合同号 = b.提货合同号 where "
Dim st As String
If Tables("S提货合同查询_Table1").count > 0 Then
For i As Integer = 0 To Tables("S提货合同查询_Table1").count -1
Dim r As Row = Tables("S提货合同查询_Table1").Rows(i)
Dim t As String = " a.提货合同号 = '" & r("提货合同号") & "' or"
st = st & t
Next
sg = sg & st
sg = sg.Trim()
sg = sg.Remove(sg.length -2,2)
If e.form.ExistControl("Table3") Then
e.form.RemoveControl("Table3")
End If
Dim tbl As WinForm.Table
tbl = e.Form.CreateSQLQuery("Table3",sg,"baox")
tbl.SetBounds(10, 10, 600, 400)
e.Form.AddControl(tbl)
tbl.visible = False
Dim dlg As New SaveFileDialog '定一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
Dim ss As String
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
ss = dlg.FileName
If FileSys.FileExists("& ss &") = True Then
FileSys.DeleteFile("& ss &",2,2) '则彻底删
End If
Tables("S提货合同查询_Table3").SaveExcel(ss,"提货合同明细",False)
End If
End If
这样也可以解决,是否妥当呢?谢指点!!