warren2600
Programmer
i've written a simple stored proc in SQL SERVER and
am running it with ASP.
The proc runs fine in Query Analyzer, returning the correct number depending if the company exists or not...1 = not exists, 0 = exists.
However I'm getting the following error ONLY when the result is 1..???
ADODB error Item cannot be found in the collection corresponding to the requested name or ordinal
see code below
Any input would be greatly appreciated.
Thanks,
warren
HERE IS THE ASP CODE:
-------------------------------------------------
Dim adoCon
dim rs
dim scompany_name
dim strsql
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = Customer_Directory; User Id = user; Password = password"
Set rs = Server.CreateObject("ADODB.Recordset")
'get company name from form
scompany_name = Request.form("company_name")
'run stored proc
strSQL = "sp_insert_new_company '" & scompany_name & "'"
rs.open strsql,adocon,adOpenStatic,adLockReadOnly,adcmdtext
'resultset returns 0 when false but errors if not 0
Response.Write rs("resultset")
rs.Close
set rs = nothing
-----------------------------------------------
/********************************************/
/** SQL STORED PROC **/
/********************************************/
CREATE PROCEDURE [dbo].[sp_insert_new_company]
@company_name varchar(250)
AS
declare @company_id int
if (not exists(select * from company where company_name = @company_name))
BEGIN
insert into company (company_name)
select @company_name
set @company_id = (select company_id from company where company_name = @company_name)
insert into technology(company_id)
select @company_id
insert into business(company_id)
select @company_id
insert into lessons(company_id)
select @company_id
insert into knowledge(company_id)
select @company_id
/*if company is new then return 1*/
select 1 as resultset
END
/* if the company exists then return 1*/
select 0 as resultset
am running it with ASP.
The proc runs fine in Query Analyzer, returning the correct number depending if the company exists or not...1 = not exists, 0 = exists.
However I'm getting the following error ONLY when the result is 1..???
ADODB error Item cannot be found in the collection corresponding to the requested name or ordinal
see code below
Any input would be greatly appreciated.
Thanks,
warren
HERE IS THE ASP CODE:
-------------------------------------------------
Dim adoCon
dim rs
dim scompany_name
dim strsql
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = Customer_Directory; User Id = user; Password = password"
Set rs = Server.CreateObject("ADODB.Recordset")
'get company name from form
scompany_name = Request.form("company_name")
'run stored proc
strSQL = "sp_insert_new_company '" & scompany_name & "'"
rs.open strsql,adocon,adOpenStatic,adLockReadOnly,adcmdtext
'resultset returns 0 when false but errors if not 0
Response.Write rs("resultset")
rs.Close
set rs = nothing
-----------------------------------------------
/********************************************/
/** SQL STORED PROC **/
/********************************************/
CREATE PROCEDURE [dbo].[sp_insert_new_company]
@company_name varchar(250)
AS
declare @company_id int
if (not exists(select * from company where company_name = @company_name))
BEGIN
insert into company (company_name)
select @company_name
set @company_id = (select company_id from company where company_name = @company_name)
insert into technology(company_id)
select @company_id
insert into business(company_id)
select @company_id
insert into lessons(company_id)
select @company_id
insert into knowledge(company_id)
select @company_id
/*if company is new then return 1*/
select 1 as resultset
END
/* if the company exists then return 1*/
select 0 as resultset