Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

It has been a while since I have done this. I know that when you want to use a text variable in your SQL statement you can do something like this:

 

strSQL = "SELECT * FROM myTable WHERE ID=" & myVariable & " ORDER BY myorder;"

 

Now my questions are as follows:

1) Is the above SQL statement correct for use against an access database using a string variable? If not what would be correct?

 

2) Is the above SQL statement correct for using a numeric variable? If not what would be correct?

 

3) Is the above SQL statement correct for using a date variable? If not what would be the correct format?

 

It has been a while and I can not remember the correct way of doing it.

 

Thanks,

 

Chester

____________________________________________

http://www.pophamcafe.com

I am starting a developers section, more tutorials than anything.

Posted

The SQL Statements would be

 

1) strSQL = "SELECT * FROM myTable WHERE String = '" & myVariable & "' ORDER BY myorder"

 

2) strSQL = "SELECT * FROM myTable WHERE Number = " & myVariable & " ORDER BY myorder"

 

3) strSQL = "SELECT * FROM myTable WHERE Date = DateValue('" & myVariable & "') ORDER BY myorder"

 

Hope This Helps

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...