Where variable > 0
-
Thursday, April 05, 2012 6:30 PM
Sub sGetLotsWithCattle() 'can this be in modcomsub? Dim resultIndex As Integer = -1 Dim str As String Dim zero As Integer = 0 'Dim SQL As String = "SELECT Location, LotNo FROM Lots WHERE AcceptAllocation = True ORDER BY Location, LotNo;" Dim SQL As String = "SELECT Location, LotNo FROM Lots WHERE Current > 0 ORDER BY Location, LotNo;" Dim LotsTab As New DataTable StrComp = fGetStrComp() Dim CompConn As New OleDbConnection(StrComp) Dim CompAdapter As New OleDbDataAdapter(SQL, CompConn) CompAdapter.Fill(LotsTab) lbLots.Items.Clear() For Each FoundRow As DataRow In LotsTab.Rows Str = FoundRow("Location") lbLots.Items.Add(FoundRow("LotNo") & " " & str) resultIndex = cbLocation.FindStringExact(str, resultIndex) If resultIndex = -1 Then cbLocation.Items.Add(str) End If Next CompConn.Close() LotsTab.Dispose() End SubUsing an Access Database and vb 2010, I am having difficulty getting data froma a database conditionally based on whether an integer value is more than zero. If you look at the code you will see a conditional based on a boolean variable and it works fine. I reduced the sql to this to test; however, I really want the SQL to be Dim SQL AsString= "SELECT Location, LotNo FROM Lots WHERE Current > 0 AND AcceptAllocation = True ORDER BY Location, LotNo;"
All Replies
-
Thursday, April 05, 2012 6:42 PM
it looks OK
here is an example
http://www.1keydata.com/sql/sqlandor.html
so my question would be are you sure Current is the correct spelling of the column name and is a column in the Lots table?
“This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.”
-
Thursday, April 05, 2012 7:17 PM
I apologize. I thought I had checked to see if Current is a restricted word; but, evidently, I erred. I just fixed by putting [Current]. Sorry
- Marked As Answer by jjobcorp Thursday, April 05, 2012 7:17 PM
-
Thursday, April 05, 2012 7:51 PMif my post helped you solve the problem, you can mark that as Answer also
“This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.”

