What's wrong with this SQL Statement
I am passing parameters to a function to select data from an SQL database.
I am looping through three arraylists to get data. My SQL statement:
Dim strSQL As String = "SELECT Stand.StandID, Stand.Block, Purchase.MgtArea, " _
& "Stand.TractNum, Purchase.TractName, BType.Btype, Strata.Stratum, " _
& "Stand.Origin, Stand.Acres, Regime.SingleChop, Regime.SpotRake, Regime.Bed " _
& "FROM (((Stand INNER JOIN Purchase ON Stand.TractNum = Purchase.PurchaseID) " _
& "INNER JOIN BType ON Stand.BType = BType.Code) " _
& "INNER JOIN Strata ON Stand.Stratum = Strata.Code) " _
& "INNER JOIN Regime ON Stand.Regimeid = Regime.RegimeID " _
& "WHERE Stand.TractNum = """ & selPurchase.Item(index) & """ AND BType.Btype = """ _
& selBType.Item(bindex) & """ And Strata.Stratum = """ & selStratum.Item(sindex) & """"
This statement doesnt return any data though it doesnt produce an error message either.
I've checked with a query in the database and data is there. Also I've checked that data
is being passed.
The loop that is passing the data:
For i = 0 To MMain.selPurchase.Count
For b = 0 To MMain.selBType.Count
For s = 0 To selStratum.Count
objStands = getStands(i, b, s)
s = s + 1
Next s
b = b + 1
Next b
i = i + 1
Next i
Also, is there a way to pass all of the array values at once and not loop?
Thanks,
dc
|