Solved

SQL 2012 PROC & Classic ASP

Posted on 2014-11-28
9
277 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
9 Comments
 
LVL 51

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 51

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 82

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
 
LVL 32

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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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 51

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 51

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now