本文介绍了如何更正查询语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用oracle 11g在vb6中设计一个程序。 (作为OLE DB(ADO))和Crystal Report(作为报表编写者)。
我写了以下查询分类帐报表。
I am designing a program in vb6 with oracle 11g. ( as OLE DB (ADO)), and Crystal Report (As report writer).
I have writing following query for a ledger report.
sSQL = "SELECT 0 AS VoucherNo ," & "'" & txtFromDt & "'" & " AS VoucherDate , Vendors.VendorName, 'Balance Brought Forward' AS Narration , " _
& " NVL(DocumentNo, 0) AS DocumentNo, 0 AS Debit, 0 AS Credit, Sum(DR-CR) AS Balance " _
& " FROM Vouchers A INNER JOIN Vendors ON A.ClientID = Vendors.VendorID" _
& " WHERE ((A.VoucherDate< " & "'" & Format(Myfrm.FromDt, "DD-MMM-YY") & "'" & " AND A.ClientID =" & "'" & Myfrm.Combo1 & "'" & " ) And Vstatus = 'Y' ) " _
& " GROUP BY DocumentNo, Voucherdate, Vendors.VendorName,'Balance Brought Forward' " _
& " UNION SELECT A.VoucherNo , A.VoucherDate , Vendors.VendorName, A.Narration, A.DocumentNo , " _
& " A.DR AS Debit, A.CR AS Credit, (Select Sum(DR-CR) FROM Vouchers Where Vouchers.ClientID=A.ClientID And " _
& " VoucherNo<= A.VoucherNo AND VStatus='Y' ) As Balance " _
& " FROM Vouchers A INNER JOIN Vendors ON A.ClientID = Vendors.VendorID " _
& " WHERE ((A.VoucherDate Between " & "'" & Format(Myfrm.FromDt, "DD-MMM-YY") & "'" & " And " & "'" & Format(Myfrm.ToDt, "DD-MMM-YY") & "'" & " )" _
& " And A.ClientID = " & "'" & Myfrm.Combo1 & "'" & " And Vstatus = 'Y') " _
& " GROUP BY A.VoucherNo, A.VoucherDate, A.ClientID, Vendors.VendorName, A.Narration,A.DocumentNo, A.DR, A.CR" _
& " Order by VoucherNo "
它在SQL Plus(Oracle)中工作正常,但是当我从vb6表单运行此查询时,它会出现以下错误< b> ORA-01790表达式必须与相应的表达式具有相同的数据类型。 < / B个我必须尽力而为,但未能解决。任何人都可以帮助查询中缺少的东西。
提前感谢。
It works fine in SQL Plus (Oracle), but when i run this query from vb6 form, It give the following error <b> ORA-01790 Expression must have same datatype as corresponding expression. </b> I have to tried by best but failed to fix. Can anybody help what is missing in query.
Thank in advance.
推荐答案
这篇关于如何更正查询语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!