Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNABLE TO USE REFERENCE TO RECORDSET OBJECT IN SQL STRING 2

Status
Not open for further replies.

TNN

Programmer
Sep 13, 2000
417
US
Please tell me, anyone, why can I not use a reference to a recordset object in a SQL string constructed for use in the OPEN statement of ADO? The string follows:

"INSERT INTO SUTATTLS(EMPNO)" _
& " VALUES(objSource3.adoRsMultiUse!EMPNO)"

Get error message "No value given for one or more required parameters".

If I remove the reference to the recordset(objSource3.adoRsMultiUse!EMPNO) and replace with a number, it works fine.

When I look at objSource3.adoRsMultiUse!EMPNO with Quick Watch it looks like a good number. What's going on???

TNN, Tom


TOM
 

try this:

"INSERT INTO SUTATTLS(EMPNO)" _
& " VALUES(" & objSource3.adoRsMultiUse!EMPNO & ")"


 
Hi,

The SQL statement is executed inside the database. The recordset inside the VB program. Two separate things.

However, What you want to do is to make up an SQL statemetn with the NUMBER (like when you hardcode it) to send to the database:

"INSERT INTO SUTATTLS(EMPNO) VALUES (" & objSource3.adoRsMultiUse!EMPNO & ")"


This will comes out as

INSERT INTO SUTATTLS(EMPNO) VALUES (10)

(assuming the tha value was 10) when the string is evaluated and send to the database. Do you see?




Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Thank You vjee and Sunaj. It sounds like what you are saying is treat the recordset object(objSource3.adoRsMultiUse!EMPNO )as a string when constructing the SQL string. I did, and it works fine.

Thank You very much.
TNN, Tom

TOM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top