Question : VB.net query problem

I have a query that I construct in VB and run against an access db. The query runs fine in Access (I can copy from sqlstring in vb and put it in an access query) but won't return any records in vb. I get no errors at all.  I can make the query run correctly (in VB)  by removing the where clause concerning the batchnumber. With the batch number in there it doesn't work.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
Sql code that runs fine in access

SELECT L.ClientID as client_num, L.LoanNumberID as loan_num FROM (tblLoan AS L INNER JOIN tblADP as A on (A.ClientID = L.ClientID AND A.LoanNumberID = L.LoanNumberID)) LEFT OUTER JOIN tblFeeResults as R on R.ClientID = L.ClientID AND R.LoanNumberID = L.LoanNumberID WHERE FeeProtectionStartDate IS NOT NULL AND FeeProtectionEndDate IS NOT NULL AND L.BatchCheckReportDate IS NULL AND R.LoanNumberID IS NULL AND R.ClientID IS NULL AND A.BatchNumber Like '2.1*' AND ((L.AcquisitionID IN ('5261009WAA','5261009WAB')) OR (Len(L.AcquisitionID) <= 6) OR (L.AcquisitionID IS NULL)) GROUP BY L.ClientID, L.LoanNumberID;

Take out AND A.BatchNumber Like '2.1*'  and it runs in vb.

vbcode building query


"SELECT L.ClientID as client_num, L.LoanNumberID as loan_num " & _
                                        "FROM (tblLoan AS L " & _
                                        "INNER JOIN tblADP as A on (A.ClientID = L.ClientID AND A.LoanNumberID = L.LoanNumberID)) " & _
                                        "LEFT OUTER JOIN " & RESULT_TABLE & " as R on R.ClientID = L.ClientID AND R.LoanNumberID = L.LoanNumberID " & _
                                        "WHERE FeeProtectionStartDate IS NOT NULL " & _
                                        "AND FeeProtectionEndDate IS NOT NULL " & _
                                        "AND L.BatchCheckReportDate IS NULL " & _
                                        "AND R.LoanNumberID IS NULL " & _
                                        "AND R.ClientID IS NULL " & _
                                        "AND A.BatchNumber Like '2.1*' " & _
                                        "AND ((L.AcquisitionID IN ('5261009WAA','5261009WAB')) OR (Len(L.AcquisitionID) <= 6) OR (L.AcquisitionID IS NULL)) " & _
                                        "GROUP BY L.ClientID, L.LoanNumberID;"

Answer : VB.net query problem

I apologize, I thought you were looking for SQL.
Random Solutions  
 
programming4us programming4us