•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 426,907 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,315 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 7170 | Replies: 0
![]() |
•
•
Join Date: Mar 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Hello,
I am attempting to make a stored procedure call to an ADO. I will paste in the try loop. Problem is code compiles and runs, however; the stored procedure never runs. It's supposed to create a row in the DB, and the row is never created. If I run the proc in a SQL query session, it runs succesfully, so I know that the proc is good. If anyone could be of any help, I would appreciate it. I am using sample code that I found at another site, my first thought was that I may have to use another function, not execute(), I'm at a loss.......
<< moderator edit: added [code][/code] tags >>
I am attempting to make a stored procedure call to an ADO. I will paste in the try loop. Problem is code compiles and runs, however; the stored procedure never runs. It's supposed to create a row in the DB, and the row is never created. If I run the proc in a SQL query session, it runs succesfully, so I know that the proc is good. If anyone could be of any help, I would appreciate it. I am using sample code that I found at another site, my first thought was that I may have to use another function, not execute(), I'm at a loss.......
try
{
HRESULT result;
//Connect to database
result = ::CoInitialize(NULL);
if (FAILED(result)) throw HookException("COM initialize failed.");
result = connection.CreateInstance(__uuidof(Connection));
if (FAILED(result)) throw HookException("Could not create connection instance.");
result = connection->Open("DSN=WFC_DSN;UID=suprkron;PWD=skron96", "", "", adConnectUnspecified);
if (FAILED(result)) throw HookException("Could not connect to database.");
result = preparedCommand.CreateInstance(__uuidof(Command));
if (FAILED(result)) throw HookException("Could not create prepared command.");
preparedCommand->CommandText = "NGP_VALLABORACCT";
preparedCommand->ActiveConnection = connection;
preparedCommand->CommandType = adCmdStoredProc;
//LL 1
vLl1.vt = VT_I2;
vLl1.iVal = ll1;
inputParam = preparedCommand->CreateParameter(_bstr_t("1"),
adInteger,
adParamInput,
sizeof(int),
vLl1);
preparedCommand->Parameters->Append(inputParam);
//LL 2
vLl2.vt = VT_I2;
vLl2.iVal = ll2;
inputParam = preparedCommand->CreateParameter(_bstr_t("2"),
adInteger,
adParamInput,
sizeof(int),
vLl2);
preparedCommand->Parameters->Append(inputParam);
//LL 3
vLl3.vt = VT_I2;
vLl3.iVal = ll3;
inputParam = preparedCommand->CreateParameter(_bstr_t("3"),
adInteger,
adParamInput,
sizeof(int),
vLl3);
preparedCommand->Parameters->Append(inputParam);
//LL 4
vLl4.vt = VT_I2;
vLl4.iVal = ll4;
inputParam = preparedCommand->CreateParameter(_bstr_t("4"),
adInteger,
adParamInput,
sizeof(int),
vLl4);
preparedCommand->Parameters->Append(inputParam);
//LL 5
vLl5.vt = VT_I2;
vLl5.iVal = ll5;
inputParam = preparedCommand->CreateParameter(_bstr_t("5"),
adInteger,
adParamInput,
sizeof(int),
vLl5);
preparedCommand->Parameters->Append(inputParam);
//LL 6
vLl6.vt = VT_I2;
vLl6.iVal = ll6;
inputParam = preparedCommand->CreateParameter(_bstr_t("6"),
adInteger,
adParamInput,
sizeof(int),
vLl6);
preparedCommand->Parameters->Append(inputParam);
//LL 7
vLl7.vt = VT_I2;
vLl7.iVal = ll7;
inputParam = preparedCommand->CreateParameter(_bstr_t("7"),
adInteger,
adParamInput,
sizeof(int),
vLl7);
preparedCommand->Parameters->Append(inputParam);
returnVal.vt = VT_I2;
returnVal.iVal = 0;
returnParam = preparedCommand->CreateParameter(_bstr_t("return"),
adNumeric,
adParamReturnValue,
sizeof(_variant_t),
returnVal);
preparedCommand->Parameters->Append(returnParam);
resultSet = preparedCommand->Execute(&rowsAffected, NULL, adCmdStoredProc);
printf("Complete, rows effected: %d", rowsAffected.lVal);
}<< moderator edit: added [code][/code] tags >>
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- PHP MySQL 5.0 stored procedure (PHP)
- How to connect a SQL stored procedure to a windows application? (VB.NET)
- Pbm with stored procedure (Oracle)
- Can return a Stored Procedure Recordset (MS SQL)
- Help with a stored procedure (MS SQL)
- Help with Stored Procedure (MS SQL)
- how do I run a "disconnected" stored procedure (MS SQL)
Other Threads in the C Forum
- Previous Thread: Reading Keypresses without a "return"
- Next Thread: Can someone help at least get started its due monday please

Linear Mode