Solved

SQL 2012 PROC & Classic ASP

Posted on 2014-11-28
9
299 Views
Last Modified: 2014-11-28
I'm trying use a Stored Procedure on a Classic ASP page in Dreamweaver. I keep getting the following error.
Microsoft OLE DB Provider for SQL Server error '80040e14'
Syntax error or access violation
mypage.asp, line 25 (set rsST3 = cmdsST3.Execute)


I did some research and I'm not sure if this is the known bug in my case:
http://support.microsoft.com/kb/812916

They recommended:
To work around this bug, use early binding instead of late binding to run the SQL query. You can use the Excecute method of the ADODB.Command object to run the SQL query, as shown in the following code:
myRecordset = myCommand.Execute(, New Object() {myParameter})

If so, not sure how to implement it on my end.
set rsST3 = cmdsST3.Execute(, New Object() {@AGE},{@INS})

Any help appreciated.

MyPROC:
ALTER PROCEDURE [myPROC]

@AGE varchar(50),
@INS varchar(50)

As

SELECT

AgeGroup AS iAge,
InSeam AS iSeam

FROM myTable AS refDetails
WHERE (',' + RTRIM(AgeGroup) + ',') LIKE '%,%' + @AGE + ',%' AND (',' + RTRIM(InSeam) + ',') LIKE '%,%' + @INS + ',%' AND (MAKE_PUBLIC = 'yes' OR MAKE_PUBLIC = 'out')
ORDER BY BPRICE ASC

Open in new window


My Page:
<%
Dim cmdsST3__AGE
cmdsST3__AGE = "2"
if(Request("AGE") <> "") then cmdsST3__AGE = Request("AGE")

Dim cmdsST3__INS
cmdsST3__INS = "15"
if(Request("INS") <> "") then cmdsST3__INS = Request("INS")
%>
<%
set cmdsST3 = Server.CreateObject("ADODB.Command")
cmdsST3.ActiveConnection = My_STRING
cmdsST3.CommandText = "myPROC"
cmdsST3.CommandType = 4
cmdsST3.CommandTimeout = 0
cmdsST3.Prepared = true
cmdsST3.Parameters.Append cmdsST3.CreateParameter("@RETURN_VALUE", 3, 4)
cmdsST3.Parameters.Append cmdsST3.CreateParameter("@AGE", 200, 1,50,cmdsST3__AGE)
cmdsST3.Parameters.Append cmdsST3.CreateParameter("@INS", 200, 1,50,cmdsST3__INS)
set rsST3 = cmdsST3.Execute
rsST3_numRows = 0
%>

<% if rsST3.eof or rsST3.bof then %>
<p>Not found.</p>

<% else %> 

<%
While Not rsST3.EOF

strAGE = rsST3("iAge")
strINS = rsST3("iSeam")
%>

<div>
  AGE: <%=strAGE%><br />
 INSEAM: <%=strINS%><br />
</div>

<%
rsST3.MoveNext()
Wend
%>

<% end if %>

Open in new window

0
Comment
Question by:swaggerking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 56

Expert Comment

by:HainKurt
ID: 40470922
comment out 14-15-16-17 and test it... will it run?

also, are you opening your db somewhere? maybe it is closed?
0
 
LVL 56

Expert Comment

by:HainKurt
ID: 40470923
like this

set conn=Server.CreateObject("ADODB.Connection")
conn.Open My_STRING

set cmdsST3 = Server.CreateObject("ADODB.Command")
cmdsST3.ActiveConnection = conn

Open in new window

0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40470948
Check the connection strings on this page: http://www.connectionstrings.com/sql-server/  You may need SQL Native Client 11 to connect to SQL Server 2012.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 33

Expert Comment

by:Big Monty
ID: 40470972
comment out line 17, you don't need to specify a return value, if anything is returned, it'll be in the recordset for you
0
 

Author Comment

by:swaggerking
ID: 40470974
@HainKurt

comment out 14-15-16-17 and test it... will it run?
I get a new error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near 'INSEAM'.
/balance-bikes/asp/search.asp, line 20 (set rsST3 = cmdsST3.Execute)


also, are you opening your db somewhere? maybe it is closed?
DB is open and running. I can and I'm currently running other PROCS that are live.

When I try this it gives me my original error.
set conn=Server.CreateObject("ADODB.Connection")
conn.Open My_STRING

set cmdsST3 = Server.CreateObject("ADODB.Command")
cmdsST3.ActiveConnection = conn

Open in new window


This PROC is a little more complex than what I usually run. I've added two additional fields in this table. AgeGroup and InSeam they both contain values separated by commas

Ie:
Product A:
AgeGroup: 2,3,4,5
InSeam:14,14.5,15,15.5,16,16.5

Product B:
AgeGroup: 3,4,5,6
InSeam:15,15.5,16,16.5,17

Each of my products belong to various age groups and inseam restrictions that may overlap from product to product. I want to allow my customers to search and find the product(s) that match their age and inseam.
0
 

Author Comment

by:swaggerking
ID: 40470978
@Big Monty
Commenting out 17 gives me the same error.
0
 
LVL 56

Accepted Solution

by:
HainKurt earned 500 total points
ID: 40471192
comment out 14-15-16-17 and test it... will it run?
I get a new error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near 'INSEAM'.

good... now it is connecting to db, running it, and you get error from database, meaning your query is wrong...

now delete line 9 &12 in your sp (delete empty lines)...

and try again
0
 
LVL 56

Expert Comment

by:HainKurt
ID: 40471194
This PROC is a little more complex than what I usually run

:) it is simplest proc i ever seen... just one select... nothing else...
0
 

Author Closing Comment

by:swaggerking
ID: 40471278
@HainKurt
It's the simple things that gets us every time. I appreciate your help and sense of humor.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question