Hi, all
I have a stored procedure created in SQL Server like the following
lines.
// stored proceudre code starts here
CREATE PROCEDURE sp_insertdata
@strdata varchar(250) ,
@rsult BIT OUTPUT ,
@erridx CHAR(7) OUTPUT
AS
BEGIN
... ...
END
GO
// stored proceudre code ends here
I want to call this stored procedure in VC++, and my C++ codes as
below:
... ...
m_pCommand->ActiveConnection = m_pConnection;
m_pCommand->CommandText="sp_insertdata";
m_pCommand->CommandType=adCmdStoredProc;
m_pCommand->Parameters->Refresh();
... ...
My question is how to define and pass parameters to the stored
procedure in VC++, Could anyone give me a reply, thanks in advance!
Joseph 3 8192
Hello,
I have a stored procedure created in SQL Server like the following
lines.
....
I want to call this stored procedure in VC++, and my C++ codes as
below:
....
My question is how to define and pass parameters to the stored
procedure in VC++, Could anyone give me a reply, thanks in advance!
This is one possible implementation:
// Input parameter.
_bstr_t strdata = L"data";
ADODB::_CommandPtr command = ADODB::_CommandPtr(ADODB::CLSID_Command);
command->CommandType = ADODB::adCmdStoredProc;
command->ActiveConnection = connection;
// SQL Server help advices against sp_ prefix in the stored procedure name.
command->CommandText = L"sp_insertdata";
ADODB::_ParameterPtr strdataParameter = command->CreateParameter(
L"@strdata",
ADODB::adBSTR,
ADODB::adParamInput,
strdata.length(),
strdata);
command->Parameters->Append(strdataParameter);
ADODB::_ParameterPtr rsultParameter = command->CreateParameter(
L"@rsult",
ADODB::adBoolean,
ADODB::adParamOutput,
1,
false);
command->Parameters->Append(rsultParameter);
ADODB::_ParameterPtr erridxParameter = command->CreateParameter(
L"@erridx",
ADODB::adChar,
ADODB::adParamOutput,
7,
L"");
command->Parameters->Append(erridxParameter);
_variant_t recordsAffected = long(0);
// Result record sets.
ADODB::_RecordsetPtr recordSet =
command->Execute(&recordsAffected, 0, ADODB::adOptionUnspecified);
// Output parameters.
bool rsult = rsultParameter->Value;
_bstr_t erridx = erridxParameter->Value;
P.S. The code is not compiled.
--
Vladimir Nesterovsky
Yes, It work perfectly, thanks Vladimir!!!
I have a new question : because strdata includes Big5 characters , the SQL
Server side procedure can not work perfectly while it can work well when I
set strdata to strings without Big5 characters, could you tell me why?
Thanks again!
Joseph
"Vladimir Nesterovsky" <vl******@nesterovsky-bros.comдÈëÏûÏ¢
news:Oc**************@TK2MSFTNGP03.phx.gbl...
Hello,
> I have a stored procedure created in SQL Server like the following lines.
...
> I want to call this stored procedure in VC++, and my C++ codes as below:
...
> My question is how to define and pass parameters to the stored procedure in VC++, Could anyone give me a reply, thanks in advance!
This is one possible implementation:
// Input parameter.
_bstr_t strdata = L"data";
ADODB::_CommandPtr command = ADODB::_CommandPtr(ADODB::CLSID_Command);
command->CommandType = ADODB::adCmdStoredProc;
command->ActiveConnection = connection;
// SQL Server help advices against sp_ prefix in the stored procedure
name.
command->CommandText = L"sp_insertdata";
ADODB::_ParameterPtr strdataParameter = command->CreateParameter(
L"@strdata",
ADODB::adBSTR,
ADODB::adParamInput,
strdata.length(),
strdata);
command->Parameters->Append(strdataParameter);
ADODB::_ParameterPtr rsultParameter = command->CreateParameter(
L"@rsult",
ADODB::adBoolean,
ADODB::adParamOutput,
1,
false);
command->Parameters->Append(rsultParameter);
ADODB::_ParameterPtr erridxParameter = command->CreateParameter(
L"@erridx",
ADODB::adChar,
ADODB::adParamOutput,
7,
L"");
command->Parameters->Append(erridxParameter);
_variant_t recordsAffected = long(0);
// Result record sets.
ADODB::_RecordsetPtr recordSet =
command->Execute(&recordsAffected, 0, ADODB::adOptionUnspecified);
// Output parameters.
bool rsult = rsultParameter->Value;
_bstr_t erridx = erridxParameter->Value;
P.S. The code is not compiled.
--
Vladimir Nesterovsky
I got it ,it is SQL server side issue, thanks to all for your help !!!
Joseph
"Joseph" <jo******@yahoo.comдÈëÏûÏ¢
news:OZ**************@TK2MSFTNGP05.phx.gbl...
Yes, It work perfectly, thanks Vladimir!!!
I have a new question : because strdata includes Big5 characters , the SQL
Server side procedure can not work perfectly while it can work well when I
set strdata to strings without Big5 characters, could you tell me why?
Thanks again!
Joseph
"Vladimir Nesterovsky" <vl******@nesterovsky-bros.comдÈëÏûÏ¢
news:Oc**************@TK2MSFTNGP03.phx.gbl...
>Hello,
>> I have a stored procedure created in SQL Server like the following lines.
...
>> I want to call this stored procedure in VC++, and my C++ codes as below:
...
>> My question is how to define and pass parameters to the stored procedure in VC++, Could anyone give me a reply, thanks in advance!
This is one possible implementation:
// Input parameter. _bstr_t strdata = L"data";
ADODB::_CommandPtr command = ADODB::_CommandPtr(ADODB::CLSID_Command);
command->CommandType = ADODB::adCmdStoredProc; command->ActiveConnection = connection;
// SQL Server help advices against sp_ prefix in the stored procedure name. command->CommandText = L"sp_insertdata";
ADODB::_ParameterPtr strdataParameter = command->CreateParameter( L"@strdata", ADODB::adBSTR, ADODB::adParamInput, strdata.length(), strdata);
command->Parameters->Append(strdataParameter);
ADODB::_ParameterPtr rsultParameter = command->CreateParameter( L"@rsult", ADODB::adBoolean, ADODB::adParamOutput, 1, false);
command->Parameters->Append(rsultParameter);
ADODB::_ParameterPtr erridxParameter = command->CreateParameter( L"@erridx", ADODB::adChar, ADODB::adParamOutput, 7, L"");
command->Parameters->Append(erridxParameter);
_variant_t recordsAffected = long(0);
// Result record sets. ADODB::_RecordsetPtr recordSet = command->Execute(&recordsAffected, 0, ADODB::adOptionUnspecified);
// Output parameters. bool rsult = rsultParameter->Value; _bstr_t erridx = erridxParameter->Value;
P.S. The code is not compiled. -- Vladimir Nesterovsky This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: 2much4u |
last post by:
Hello,
I have a stored procedure and I want to pass it a NUMBER parameter to
make a select inside it as the following:
SELECT *
FROM example_table
WHERE example_table.id IN...
|
by: Michael |
last post by:
This one's really got me. I have a VB.NET (version 1.1.4322) project
that provides an easy way to execute stored procedures on a generic
level. When I run the code on computer A (running SQL...
|
by: Mark Flippin |
last post by:
This is for a reporting problem using:
Access 2000
SQL Server 2000
Both at SP3
I've a stored procedure in SQL Server 2000 which builds a result set
from a disparate set of tables, utilizing...
|
by: Bill Nguyen |
last post by:
What's the VB syntax to run the CR report using the following SP?
I use CrystalreportViewer and ReportDocument.
Thanks
Bill
Here's the SP in SQLserver 2K:
CREATE proc mysp_ReportSubmission...
|
by: IamtheEvster |
last post by:
Hi All,
I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am
unable to call a MySQL stored procedure that returns output parameters
using mysql, mysqli, or PDO. I'm having a...
|
by: ric_deez |
last post by:
Hi there, I would like to create a simple search form to allow users to
search for a job number based on a number of parameters. I think I
understand how to use parameteres associated with Stored...
|
by: pinman |
last post by:
hi i am trying to implemement forms authentication for my website but can't seem to get the stored procedure to output the correct value when checking a users credentials. the code is
ALTER...
|
by: jamesclose |
last post by:
My problem is this (apologies if this is a little long ... hang in there):
I can define a function in VB.NET with optional parameters that wraps a SQL procedure:
Sub Test(Optional ByVal Arg1...
|
by: cmrhema |
last post by:
Hi,
Kindly excuse if I am posting in the wrong place.
I am using Visual Studio 2008, .net framework 3.5, asp.net , c# and sql server 2005.
I am supposed to pass stored procedures from client...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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: 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,...
|
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...
| |