General discussion

Locked

Passing parameters from VB6 to SQL

By setivi ·
Dim intVal as Integer
intval = 2020
qconn.Execute("Select * from Table1 where userid=intval")

The question is how can I make sql recognize or accept intval as a predefined variable in VB6 and run the query with resultset based on the value of intval?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Dennis.Keeling In reply to Passing parameters from ...

You need to ensure that the substitution takes place before the statement is executed.

"SELECT * FROM Table1 WHERE [UserID} =" & intval

Collapse -

by setivi In reply to

Gave me the basic idea and was helpful.

Collapse -

by Dragon Emperor In reply to Passing parameters from ...

Dim intVal as Integer
intval = 2020
qconn.Execute("Select * from Table1 where [userid]=" & CStr(intval))

As an alternative you could use a command object with parameters, but the above is the simplest to get the result you want.

Collapse -

by setivi In reply to

The best answer so far and helped me to solve my problem. Thanks a million!

Collapse -

by setivi In reply to Passing parameters from ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums