I posted this in the C++ section but didn’t get any responses so I thought it might be more appropriate here.
I’m trying to call a stored procedure on my SQL 2008 server with the below code. When I look at the query with the SQL profiler I get the following: - exec GetUserID @Email='test@email.com',@Password='@Email'
What I expect to get is: - exec GetUserID @Email='test@email.com',@Password='123456'
It seems as if the first parameter is stepping on the second. As ‘@Email’ is a remnant of the first. Can someone explain what is going on? -
#include "stdafx.h"
-
-
#import "C:\Program Files\Common Files\System\ado\msado15.dll" rename("EOF", "EndOfFile")
-
-
int _tmain(int argc, _TCHAR* argv[])
-
{
-
try
-
{
-
::CoInitialize(NULL);
-
-
ADODB::_ConnectionPtr ConnectionPtr = NULL;
-
ADODB::_CommandPtr CommandPtr = NULL;
-
ADODB::_ParameterPtr ParameterPtr = NULL;
-
-
char ConnectionString[200] = "Provider=SQLNCLI10; Server=IL47WS030501; Database=Demo; Trusted_Connection=yes;";
-
-
ConnectionPtr.CreateInstance(__uuidof(ADODB::Connection));
-
-
if(ConnectionPtr)
-
{
-
ConnectionPtr->Open(ConnectionString, "", "", 0);
-
}
-
-
CommandPtr.CreateInstance(__uuidof(ADODB::Command));
-
-
if(ConnectionPtr && CommandPtr)
-
{
-
CommandPtr->ActiveConnection = ConnectionPtr;
-
CommandPtr->CommandType = ADODB::adCmdStoredProc;
-
CommandPtr->CommandText = _bstr_t("GetUserID");
-
CommandPtr->NamedParameters = true;
-
-
VARIANT vEmail;
-
vEmail.vt = VT_BSTR;
-
vEmail.bstrVal = _bstr_t("test@email.com");
-
-
VARIANT vPassword;
-
vPassword.vt = VT_BSTR;
-
vPassword.bstrVal = _bstr_t("123456");
-
-
CommandPtr->Parameters->Append(CommandPtr->CreateParameter(_bstr_t("@Email"), ADODB::adVarChar, ADODB::adParamInput, sizeof(vEmail), vEmail));
-
CommandPtr->Parameters->Append(CommandPtr->CreateParameter(_bstr_t("@Password"), ADODB::adVarChar, ADODB::adParamInput, sizeof(vPassword), vPassword));
-
-
ADODB::_RecordsetPtr RecordsetPtr = CommandPtr->Execute(NULL, NULL, ADODB::adCmdStoredProc);
-
}
-
-
return 0;
-
}
-
catch(...)
-
{
-
}
-
}
1 8145
I don’t know the details of why but I was able to get it working using the following code without a VARIANT instead: - CommandPtr->Parameters->Append(CommandPtr->CreateParameter(_bstr_t("@Email"), ADODB::adVarChar, ADODB::adParamInput, 50, "test@email.com"));
-
CommandPtr->Parameters->Append(CommandPtr->CreateParameter(_bstr_t("@Password"), ADODB::adVarChar, ADODB::adParamInput, 50, "123456"));
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dinesh prasad |
last post by:
I'm trying to use a servlet to process a form, then send that data to
an SQL server stored procedure. I'm using the WebLogic 8 App. server.
I am able to retrieve database information, so I know my...
|
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft...
|
by: Thomasb |
last post by:
With a background in MS SQL Server programming I'm used to temporary
tables. Have just started to work with DB2 ver 7 on z/OS and stumbled
into the concept of GLOBAL TEMPORARY TABLE.
I have...
|
by: Dino L. |
last post by:
How can I run stored procedure (MSSQL) ?
|
by: larry mckay |
last post by:
Hi,
I'd like to use a datagrid with a
1. most grid's use SQL data adapters as a datasource. I'd like to use
a parametrized query into a stored procedure (specifically a
sqldatareader)...
|
by: kd |
last post by:
Hi All,
How to debug a stored procedure?
Thanks,
kd
|
by: jed |
last post by:
I have created this example in sqlexpress
ALTER PROCEDURE .
@annualtax FLOAT
AS
BEGIN
SELECT begin1,end1,deductedamount,pecentageextra
FROM tax
|
by: SOI_0152 |
last post by:
Hi all!
Happy New Year 2008. Il hope it will bring you love and happyness
I'm new on this forum.
I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c.
Everything works...
|
by: Ajaxx |
last post by:
I’m trying to call a stored procedure on my SQL 2008 server with the below code. When I look at the query with the SQL profiler I get the following:
exec GetUserID...
|
by: gyanendar |
last post by:
How can i run parametrized input(2) stored procedure with 3 results fields on SQL prompt?
Please help.
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |