Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 20128, Using ADO named parameters MSSQL

by Neil Tevepaugh Email: Anonymous


The example provided in C++ Builder Help "Handling command parameters" doesn't work as written!
Download Details
FTP  download also available 0 bytes
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For C++Builder, Version 2.0  to 2.0 6 downloads
Copyright: No significant restrictions


Size: 0 bytes
Updated on Wed, 28 May 2003 13:13:44 GMT
Originally uploaded on Wed, 28 May 2003 13:14:09 GMT
Description
Code from Borland's Help
ADOCommand1->CommandText = "INSERT INTO Talley ";
ADOCommand1->CommandText += "(Counter) ";
ADOCommand1->CommandText += "VALUES (:NewValueParam)";
ADOCommand1->CommandType = cmdText;
ADOCommand1->Parameters->ParamByName("NewValueParam")->Value = 57;
ADOCommand1->Execute()

Aside from the obvious missing semicolon on the last statement, I can not make the above example work with MSSQL server. The fix is to create the CommandText in one line:

ADOCommand1->CommandText = "INSERT INTO Talley(Counter) VALUES(:NewValueParam)";
ADOCommand1->CommandType = cmdText;
ADOCommand1->Parameters->ParamByName("NewValueParam")->Value = 57;
ADOCommand1->Execute();

It appears that as soon as the CommandText is set, it is evaluated for parameters. If not found, the function errors never to try again.

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04