MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 15th, 2006, 06:31 AM
mikedark mikedark is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 1 mikedark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 49 sec
Reputation Power: 0
Post VB.net Variables in SQL Queries

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.

Reply With Quote
  #2  
Old March 27th, 2007, 01:17 AM
Maz2331 Maz2331 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 12 Maz2331 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > VB.net Variables in SQL Queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT