|
-
Oct 14th, 2003, 07:28 PM
#1
Thread Starter
Lively Member
ADO Command SQL Statement w/ variable *Resolved*
Sry if the title of the thread sucks but I am creating a command incode for my program and I am not sure if I wrote it quite right as i am not sure of how to add a variable to a SQL statement in VB so here is the code can you tell me if it is done right please.
Thx in advance
VB Code:
With m_adoCommandAR
.CommandText = "SELECT Square_Name0, Square_Name1, Square_Name2, " & _
"Square_Name3, Square_Name4, Square_Name5, " & _
"Square_Name6, Square_Name7, Square_Name8, " & _
"Square_Name9, FROM Areas WHERE Area_Name = " & _
RoomName 'The variable
.CommandType = adCmdText
.ActiveConnection = m_adoConnection
End With
Last edited by Tek; Oct 15th, 2003 at 05:44 AM.
===============
Tek
===============
-
Oct 14th, 2003, 08:07 PM
#2
Thread Starter
Lively Member
I know I am annoying lol. However, I can do this no problem in PHP but never did a sql statement in vb b4.
===============
Tek
===============
-
Oct 14th, 2003, 10:15 PM
#3
Re: ADO Command SQL Statement w/ variable
VB Code:
With m_adoCommandAR
.CommandText = "SELECT Square_Name0, Square_Name1, Square_Name2, " & _
"Square_Name3, Square_Name4, Square_Name5, " & _
"Square_Name6, Square_Name7, Square_Name8, " & _
"Square_Name9, FROM Areas WHERE Area_Name = '" & RoomName & "';"
'The variable
.CommandType = adCmdText
.ActiveConnection = m_adoConnection
End With
I just put a single quote around RoomName. If the variable is a string, then put single quotes around it, else if it's a numeric value, then don't put any quotes around it.
HTh
-
Oct 15th, 2003, 05:44 AM
#4
Thread Starter
Lively Member
Thx Again
===============
Tek
===============
-
Oct 15th, 2003, 05:57 AM
#5
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|