Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL stored procedure works in Query Analyzer but not in ASP

Status
Not open for further replies.

Edcrosbys

ISP
Apr 26, 1999
112
US
My stored procedure works fine in Query Analyzer, but not at all in ASP. Any help would be GREATLY appreciated!!!

The enviroment:
2k Server
SQL 2k
IIS 5.0

The ASP:
Code:
if Request.QueryString("dothis")="Add" then
     
   	Set conn = Server.CreateObject("ADODB.Connection")
   	conn.Open "LampeRoy"
   	   	
   	sp ="sp_AddJob '" & request.querystring("s_jobid") &"','"
   	sp = sp &Request.QueryString("s_description")&"',"
	
	IF (Request.QueryString("s_proposed") = "on") Then
    		sp = sp & "1,"
	Else
		sp = sp & "0,"
	End If
	
	IF (Request.QueryString("s_proposed_date") = "") Then
		sp = sp & "NULL,"
	Else
		sp = sp &"'"& Request.QueryString("s_proposed_date")&"',"	
	End If	
	
	IF (Request.QueryString("s_assigned") = "on") Then
    		sp = sp & "1,"
	Else
 		sp = sp & "0,"
	End If
	
	IF (Request.QueryString("s_assigned_date") = "") Then
		sp = sp & "NULL,"
	Else
		sp = sp &"'"& Request.QueryString("s_assigned_date")&"',"	
	End If	
	
	IF (Request.QueryString("s_active") = "on") Then
    		sp = sp & "1,"
	Else
 		sp = sp & "0,"
	End If

	IF (Request.QueryString("s_active_date") = "") Then
		sp = sp & "NULL,"
	Else
		sp = sp &"'"& Request.QueryString("s_active_date")&"',"	
	End If	
	
	IF (Request.QueryString("s_canceled") = "on") Then
    		sp = sp & "1,"
	Else
		sp = sp & "0,"
	End If

	
	IF (Request.QueryString("s_canceled_date") = "") Then
		sp = sp & "NULL,"
	Else
		sp = sp &"'"& Request.QueryString("s_canceled_date")&"',"	
	End If	
	
	IF (Request.QueryString("s_delivered") = "on") Then
    		sp = sp & "1,"
	Else
		sp = sp & "0,"
	End If

	IF (Request.QueryString("s_delivered_date") = "") Then
		sp = sp & "NULL,'"
	Else
		sp = sp &"'"& Request.QueryString("s_delivered_date")&"','"	
	End If	
	
	sp = sp & Request.QueryString("s_employeeinit")&"','"
	sp = sp & Request.QueryString("s_clientcompany")&"','"
	sp = sp & Request.QueryString("s_clientcontact")&"','"
	sp = sp & Request.QueryString("s_workdone")&"',"
	IF (Request.QueryString("MinNum") = "") Then
		sp = sp & "NULL,"
	Else
		sp = sp &"'"& Request.QueryString("MinNum")&"','"	
	End If	
	
	IF (Request.QueryString("MaxNum") = "") Then
		sp = sp & "NULL,"
	Else
		sp = sp &"'"& Request.QueryString("MaxNum")&"','"	
	End If	
	
	IF (Request.QueryString("finalprice") = "") Then
		sp = sp & "NULL"
	Else
		sp = sp &"'"& Request.QueryString("finalprice")&"'"	
	End If	
	response.write(sp)
	conn.Execute sp,-1,4
        conn.close
End if


The SP:
Code:
REATE PROC sp_AddJob (@JobID char (10), @Description varchar (1000), @Proposed bit, @proposed_date smalldatetime,  @Assigned bit, @Assigned_date smalldatetime, @Active bit, @Active_date smalldatetime, @Canceled bit, @Canceled_date smalldatetime, @Delivered bit, @Delivered_date smalldatetime, @EmployeeInit varchar (3), @ContactName varchar (30), @CompanyName varchar (50), @WorkDone varchar (50), @MinEstimate numeric (12), @MaxEstimate numeric (12), @DeliveredPrice numeric (12))
 AS
DECLARE @EmployeeID int, @ContactID int, @CompanyID int, @WorkID int
Select @EmployeeID =  ID from Employee where Initials = @EmployeeInit AND Appraiser != '0' 
select @CompanyID = ID from company where name = @CompanyName
select @ContactID = ID from contact where FN = @ContactName AND CompID = @CompanyID
select @WorkID = ID from work where done = @WorkDone

IF @EmployeeID IS NULL
begin
INSERT INTO Employee (Initials, access, appraiser) values (@EmployeeInit, 3, 1)
Select @EmployeeID =  ID from Employee where Initials = @EmployeeInit AND Appraiser != '0'
end

IF @CompanyID IS NULL
begin
INSERT INTO Company (Name) values (@ContactName)
select @CompanyID = ID from company where name = @CompanyName
end


IF @ContactID IS NULL
begin
INSERT INTO Contact (FN, CompID) values (@ContactName, @CompanyID)
select @ContactID = ID from contact where FN = @ContactName and CompID = @CompanyID
end


IF @WorkID IS NULL
begin
INSERT INTO work (done) values (@WorkDone)
select @WorkID = ID from work where done = @WorkDone
end

INSERT INTO job (id, description, Proposed, Proposed_date, Active, Active_date, Assigned, Assigned_Date, Canceled, Canceled_date, Delivered, Delivered_date, EmployeeID, WorkDone, ContactID, MinEstimate, MaxEstimate, DeliveredPrice) values (@Jobid, @Description, @Proposed, @Proposed_date, @Active, @Active_date, @Assigned, @Assigned_date, @Canceled, @Canceled_date, @Delivered, @Delivered_date, @EmployeeID, @WorkID, @ContactID, @MinEstimate, @MaxEstimate, @DeliveredPrice)
GO

I can Cut what the ASP page outputs to screen and paste into Query Analyzer and it works fine!!! It's driving me crazy...

Help Me Please!!!

Thanks Ahead of Time,
EdCrosbys
 
Here was the fix:
I was told to check the Stored Proc Permissions. That fixed my problem. I also found out why I was without error:
on error resume next
Was in My Asp code. One line before I cut for the article.
EdCrosbys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top