
March 27th, 2007, 01:17 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 12
Time spent in forums: 2 h 57 m 53 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by mikedark Hey guys, im having a problem with the SQL syntax for using VB.NET variables in an SQL statement.
I currently have a dataset in VB.net with a field 'Quantity'. Basicly, I have a variable within my VB code that will become part of my WHERE statement for querying that field.. eg..
VB Code....
Dim QuantityVar As Single = 11
SQL Statement....
SELECT quantity
FROM stock
WHERE (quantity > QuantityVar)
^This is the variable defined in VB
If anyone has any hints or explinations, that would be excellent.
Cheers guys!
Mike. |
I'd try composing the SQL dynamically. Try something like...
QryStr = "SELECT quantity FROM stock WHERE (quantity > " & str(QuantityVar) & ") "
Then assigne QryStr as the RecordSource to whatever you're using it with. It may help.
|