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'
Can someone explain what is going on please? - #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 3350
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: nobody |
last post by:
hello everybody,
is there a way of creating an array with help of a function that would
accept the name of this array as a parameter and then create global
Array type variable of that name?
so...
|
by: Rhino |
last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a
Throwable back to the calling program as an OUT parameter?
If yes, what datatype should I use when registering the...
|
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: Dabbler |
last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the
following error when trying to update (ExecuteNonQuery):
System.Data.SqlClient.SqlException: Procedure or Function...
|
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: Ajaxx |
last post by:
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: 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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |