以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 多数据库数据查询 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=107221) |
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:扶风 -- 发布时间:2017/9/23 17:53:00 -- 多数据库数据查询 Dim cmd1 As New SQLCommand cmd1.C cmd1.CommandText ="(S elect [FPrintNo] from {SHProcRptMain} where [FBillNo]=(S elect [FSourceBillNo] from {vwICBill_2} where FBatchNo = \'" & dr("批号") & "\'))" Dim T1 As New QueryBuilder T1.TableName = "T1" T1.S electString = cmd1.CommandText T1.Build \'Dim cmd2 As New SQLCommand \'cmd2.C \'cmd2.CommandText ="(S elect 数据 from 电容出厂 where 客户料号=tbl.Current("客户对应物料代码") And 打印标记=cmd1)" 老师,2个数据库的内容如何连起来查询?另子查询查出来的结果是数组不唯一,如何处理最后得出惟一值? S elect 数据 from 电容出厂 where 客户料号=tbl.Current("客户对应物料代码") And 打印标记=(S elect [FPrintNo] from {SHProcRptMain} where [FBillNo]=(S elect [FSourceBillNo] from {vwICBill_2} where FBatchNo = \'" & dr("批号") & "\'))
[此贴子已经被作者于2017/9/23 17:55:45编辑过]
|
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:扶风 -- 发布时间:2017/9/24 9:32:00 -- Dim g0 As String Dim g1 As String Dim cmd1 As New SQLCommand cmd1.C cmd1.CommandText ="(S elect top 5000 [FPrintNo] as [随工单号] from {SHProcRptMain})" g0 = cmd1.ExecuteScalar() g1 = Mid(g0,1,Instr(g0,"$")-1)+Right(g0,4) MessageBox.Show(g1) 请教一下,上述代码,为何会有报错:参数“Length”必须大于或等于 0。? |
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:扶风 -- 发布时间:2017/9/24 10:24:00 -- 2楼的问题解决了,应该是有空值。筛掉了就可以了。谢谢! Dim g0 As String Dim g1 As String Dim cmd1 As New SQLCommand cmd1.C cmd1.CommandText ="(S elect top 5000 [FPrintNo] as [随工单号] from {SHProcRptMain} where [FPrintNo]<>\' \')" g0 = cmd1.ExecuteScalar() g1 = Mid(g0,1,Instr(g0,"$")-1)+Right(g0,4) MessageBox.Show(g1) |
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:扶风 -- 发布时间:2017/9/24 13:42:00 -- 老师您好, 多数据源查询统计,我们如下这样做了,但是有报错,烦请您帮忙看看问题可能出在哪里? Dim dt1 As DataTable Dim cmd1 As New SQLCommand cmd1.C cmd1.CommandText ="S elect top 5000 [FPrintNo] as [随工单号],[FBillNo] as [FCR号] from {SHProcRptMain} where [FPrintNo]<>\' \' group by [FPrintNo],[FBillNo]" dt1 = cmd1.ExecuteReader Dim dt2 As DataTable Dim cmd2 As New SQLCommand cmd2.C cmd2.CommandText ="S elect top 5000 [FBatchNo] as [产品批号],[FSourceBillNo] as [FCR号] from {vwICBill_2} where [FSourceBillNo]<>\' \' group by [FBatchNo],[FSourceBillNo]" dt2 = cmd2.ExecuteReader Dim dt3 As DataTable Dim cmd3 As New SQLCommand cmd3.C cmd3.CommandText ="S elect [客户料号],[打印标记] as [随工单号],[数据] from {电容出厂} where [打印标记]<>\' \' group by [客户料号],[打印标记],[数据]" dt3 = cmd3.ExecuteReader Dim dt4 As DataTable Dim cmd4 As New SQLCommand cmd4.C cmd4.CommandText ="S elect [客户料号],[批号],[实发数量] from {销售出库单}" dt4 = cmd4.ExecuteReader Dim hbsql As String ="s elect a.*,(s elect b.[数据] from {dt3} b where a.[客户料号]=b.[客户料号]) as [测试数据],(s elect [打印标记] c.from {dt3} c where a.[客户料号]=c.[客户料号]) as [随工单号],(s elect d.[FSourceBillNo] from {dt2} d where a.[批号]=d.[FBatchNo]) as [产品批号],(S elect e.[购货单位],e.[客户料号],e.[批号],e.[实发数量] from {dt4} e group by [客户料号],[批号]) a" Dim q As new QueryBuilder q.TableName = "查询表1" q.SelectString = hbsql q.Build |
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/9/24 22:03:00 -- 两个数据库,可以直接查询的。你可以用 连接查询join,也可以用union,如
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=78783&skin=0
没有你这种语句,参考
http://www.foxtable.com/webhelp/scr/2305.htm
|
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:扶风 -- 发布时间:2017/9/26 17:48:00 -- 此主题相关图片如下:1.bmp 老师,单个字段表格里字符串长度不够怎么办?一直弹窗,是否能解决最大长度的问题? Dim sql3 As String ="S elect Top 10 * From {电容出厂}"
Dim cmd3 As New SQLCommand cmd3.C Dim dt3 As DataTable Dim cmb3 As WinForm.ComboBox cmd3.CommandText = sql3 dt3 = cmd3.ExecuteReader() Dim f3 As New Filler f3.SourceTable = dt3 f3.DataTable = DataTables("电容出厂") f3.Fill() |
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/9/26 18:27:00 -- 不能设置成【备注】类型? |
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:扶风 -- 发布时间:2017/10/25 18:31:00 --
老师,如上,如何根据B,C 2个相同字段,将2个不同数据库的表的相关内容整合到FOX的外部数据表SQL表里?
|
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:有点甜 -- 发布时间:2017/10/25 20:43:00 -- 添加两个数据源,用代码直接去查找表格数据处理
http://www.foxtable.com/webhelp/scr/2137.htm
|
||||||||||||||||||||||||||||||||||||||||||||||||
-- 作者:扶风 -- 发布时间:2017/10/27 16:30:00 -- S ELECT TOP 100 ibe.FBatchNo,i.FBillNo,t3.FFlowCardNo,ib.FBillNo,t4.FCardSort FROM ICStockBill AS ib INNER JOIN ICStockBillEntry AS ibe ON ib.FInterID=ibe.FInterID INNER JOIN ICMO AS i ON i.FInterID=ibe.FICMOInterID INNER join ICShop_FlowCard t3 ON t3.FSourceBillNo=i.FBillNo inner join (s elect distinct FCardSort,FID from Item999) as t4 on t4.FID=t3.FID 老师,如上这么一长串,Dim sql As String =“如上” 因为窗口小,连成一行容易眼花,能否像上面这样在SQL里分行来写进DIM里面? |