473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

PHP with ADO stored procedures in SQL Server 2000

Jim
here is the problem..

When this procedure runs I am supposed to get 2 output parameters.
When an insert statement is going to generate duplicate names I get 1
for @checker and 3 for @insertid. When the Insert statement runs
properly I am supposed to get 2 for @checker and an actual identity
for @insertid.

When using the code below, the part where the insert statement is
unsuccessful works just as desired, however the part where it inserts
the record returns zeros for both parameters.

When the stored procedure is run using query analyzer it performs
correctly in both instances.

Here is my PHP code

$cmd = new COM("ADODB.Command", NULL, CP_UTF8);
$cmd->CommandText = "STP_insertartist";
$cmd->CommandType = 4;
$cmd->ActiveConnection = $conn;
$par=$cmd->Parameters;
$par->Append($cmd->CreateParameter("@firstname",200,1,50,$_POST["txtfname"]));
$par->Append($cmd->CreateParameter("@lastname",200,1,50,$_POST["txtlname"]));
$par->Append($cmd->CreateParameter("@livedate1",3,1,9,$begdate));
$par->Append($cmd->CreateParameter("@livedate2",3,1,9,$enddate));
$par->Append($cmd->CreateParameter("@style",200,1,300,$_POST["txtstyle"]));
$par->Append($cmd->CreateParameter("@datedescription",200,1,75,$date text));
$par->Append($cmd->CreateParameter("@insertid",3,2,4));
$par->Append($cmd->CreateParameter("@checker",3,2,4));
$rec=$cmd->Execute;
$invid=$cmd->Parameters["@insertid"]->Value;
$check=$cmd->Parameters["@checker"]->Value;
echo("Check: ".$check." Invid: ".$invid);
here is my SQL Stored Procedure:

CREATE procedure STP_insertartist
(@firstname nvarchar(50), @lastname nvarchar(50), @livedate1 int,
@livedate2 int, @style varchar(300), @datedescription varchar(75),
@insertid int OUTPUT, @checker int output)

as
declare @check int
select @check = artistid from artist where firstname = @firstname and
lastname = @lastname

If @check is null
begin

insert into artist (firstname, lastname, livedate1, livedate2, style,
datedescription)
values(@firstname, @lastname, @livedate1, @livedate2, @style,
@datedescription)

set @insertid = scope_identity()
set @checker = 2

end

If @check is not null
begin
set @checker = 1
set @insertid = 3
end
GO

thanks

-Jim
Jul 17 '05 #1
0 4381

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ryan | last post by:
We have a suppliers application that runs a stored procedure (one of many). This stored procedure then calls various other ones etc... and the final number of stored procedures run is 11. Now,...
4
by: TJ Olaes | last post by:
Hello all, this is my second post to this newsgroup. It's a question about stored procedures and permissions and how these behave between databases. Here's the scenario. I have a database that...
17
by: serge | last post by:
How can i delete all user stored procedures and all table triggers very fast in a single database? Thank you
1
by: Karl | last post by:
Hi, I am trying to put SQL Server Stored Procedures into Sourcesafe as per the Microsoft Knowledge Base article 818368, but have run into a problem. The web server is SQL Server 2000 running on...
11
by: jrefactors | last post by:
I want to know the differences between SQL Server 2000 stored procedures and oracle stored procedures? Do they have different syntax? The concept should be the same that the stored procedures...
1
by: rdshultz | last post by:
Good morning everyone. Could someone tell me if there is a book out there which gives examples of both VB.net code and creating SQL Server 2000 stored procedures and how you get them to work...
2
by: mike | last post by:
H There are two ways to execute a stored procedure using ADO.NE - call "exec sp_myproc val1,val2" statement over SqlCommand myCommand = new SqlCommand(SQLQuery, mySqlConnection) - use...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
1
by: nickwilson.nick | last post by:
I have several stored procedures, created in a development environment, that I need to move to a 'QA' environment, and then in turn, to various production environments. When I move these stored...
0
by: Ryan | last post by:
PLEASE HELP!! I am trying to do what I think should be the simplest thing. In Visual Studio 2005, I set up a datagrid and then went ot configure a datasource for it. I made my connection to...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
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,...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.