我正在处理遗留的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 Database Desktop中运行此查询时,它可以正常工作。
更新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:\DBTOFTP\BUFF;DefaultDir=C:\DBTOFTP\BUFF;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
答案 0 :(得分:4)
一些旧的驱动程序通常要求必须在括号中包含多个JOIN。
尝试这样的事情:
FROM
(
"CHECK" C
INNER JOIN
"RCHECK" R
ON C.Cnum = R.Cnum
)
INNER JOIN
"PCHECK" P
ON P.Cnum = C.Cnum