我正在处理一个遗留的 VB6 项目,我需要像这样进行 JOIN 调用:
SELECT C.Cnum, C.RealDate, M.Name, R.Price, R.Qnt, R.RealPrice, R.QntP, R.QntR, M.Name
FROM "CHECK" C
LEFT JOIN "RCHECK" R ON C.Cnum = R.Cnum
LEFT JOIN "PCHECK" P ON C.Cnum = P.Cnum
LEFT JOIN "MONEY" M ON P.Curency = M.Sifr
LEFT JOIN "MENU" MN ON R.Sifr = MN.Sifr
WHERE C.Cnum > 0 ORDER BY C.Cnum
我使用 "Driver={Microsoft Paradox Driver (*.db )};DriverID=538"
作为连接字符串的一部分,但它似乎不支持多个连接!这很奇怪。
任何想法如何解决/解决方法?
是的,当我在Borland数据库桌面中运行此查询时,它工作正常。
更新 1:
我的VB代码:
Dim Conn As New ADODB.Connection
Dim sConnStr As String
Dim sQuery As String
sConnStr = "Driver={Microsoft Paradox Driver (*.db )};DriverID=538;Fil=Paradox 5.X;CollatingSequence=ASCII;DBQ=C:DBTOFTPBUFF;DefaultDir=C:DBTOFTPBUFF;PWD=SOMEPASS;"
sQuery = "SELECT C.Cnum, C.RealDate, M.Name, R.Price, R.Qnt, R.RealPrice, R.QntP, R.QntR, M.Name " & _
"FROM ""CHECK"" C " & _
"LEFT JOIN ""RCHECK"" R ON C.Cnum = R.Cnum " & _
"LEFT JOIN ""PCHECK"" P ON C.Cnum = P.Cnum " & _
"LEFT JOIN ""MONEY"" M ON P.Curency = M.Sifr " & _
"LEFT JOIN ""MENU"" MN ON R.Sifr = MN.Sifr " & _
"WHERE C.Cnum > 0 " & _
"ORDER BY C.Cnum"
Conn.ConnectionString = sConnStr
Conn.Open
一些旧的驱动程序通常要求多个 JOIN 必须括在括号中。
尝试这样的事情:
FROM
(
"CHECK" C
INNER JOIN
"RCHECK" R
ON C.Cnum = R.Cnum
)
INNER JOIN
"PCHECK" P
ON P.Cnum = C.Cnum