Print Page | Close Window

ASP SQL problems

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=15479
Printed Date: 30 March 2026 at 3:25am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP SQL problems
Posted By: pjb007
Subject: ASP SQL problems
Date Posted: 16 June 2005 at 11:27am
I am having problems with some ASL/SQL but I can't post here, I type the message put the code in the CODE tags put the subject and it says I must type a message.  Is there somewhere I can post me code for a sombody to take a look at it?



Replies:
Posted By: dpyers
Date Posted: 16 June 2005 at 11:51am
Code tags have been a little flakey lately - it is an alpha forume - lol.

Try putting it in quote tags.


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: pjb007
Date Posted: 16 June 2005 at 12:03pm
I get the same error message


Posted By: pjb007
Date Posted: 16 June 2005 at 12:05pm
The error I get is
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/peterbonduk/links_test.asp, line 38
 
Error shown in Bold Red Text
 

<table width="100%"  border="0">

  <tr>
   
<td colspan="2"><!--#include file="nav/titles/hometitle.asp" --> <hr /></td>

  </tr>
  <tr>

    <td width="20%" valign="top"><!--#include file="nav/menus/indexmenu.asp" --></td>

    <td width="80%" valign="top"><p class="kwd4"><strong>Computer Links</strong><br />
      <%
dim Conn 
dim FilePath 
dim SQL
dim RSUser 
dim Counter
 
'Connection to Database
Set Conn = Server.CreateObject("ADODB.Connection")
FilePath = Server.MapPath("db/db1.mdb")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & FilePath & ";"
 

'SQL Query String

if request("state") = "computer" then
SQL = "Select * FROM tbl_linkstest WHERE display=yes AND cat=computer ORDER BY titletext ASC"

end if
 
'Set the Recordset
Set RSUser = Conn.Execute (SQL)
 
'Print the Recordset
RSUser.Movefirst
%>
     
    </p>

      <table width="100%">
<%Do While not RSUser.eof%>
<tr class="kwd4">

<td width="50%"><% Response.Write ("<a href=""" & "http://" & RSUser("url") & """ target=""_blank"">") & RSUser("titletext") & ("</a>") %></td>

<% RSUser.MoveNext
if RSUser.EOF then %>
<td width="50%">&nbsp;</td>
<tr class="kwd4">

<td width="100%" colspan="2">&nbsp;</td>
<% Exit Do
else %>
<td width="50%"><% Response.Write ("<a href=""" & "http://" & RSUser("url") & """ target=""_blank"">") & RSUser("titletext") & ("</a>") %></td>

<% RSUser.MoveNext
end if%>
</tr>
<tr class="kwd4">
<td width="100%" colspan="2">&nbsp;</td>
</tr>
<% Loop %>
</table>


Posted By: dj air
Date Posted: 16 June 2005 at 1:02pm
before the red part ypu meed to make it a recordset ie

Set RSUser= Server.CreateObject("ADODB.RecordSet")


Posted By: pjb007
Date Posted: 16 June 2005 at 1:20pm
The error I get now is
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/peterbonduk/links_test.asp, line 39
 
Error shown in Bold Red Text

<table width="100%"  border="0">

  <tr>
   
<td colspan="2"><!--#include file="nav/titles/hometitle.asp" --> <hr /></td>

  </tr>
  <tr>

    <td width="20%" valign="top"><!--#include file="nav/menus/indexmenu.asp" --></td>

    <td width="80%" valign="top"><p class="kwd4"><strong>Computer Links</strong><br />
      <%
dim Conn 
dim FilePath 
dim SQL
dim RSUser 
dim Counter
 
'Connection to Database
Set Conn = Server.CreateObject("ADODB.Connection")
FilePath = Server.MapPath("db/db1.mdb")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & FilePath & ";"
 

'SQL Query String

if request("state") = "computer" then
SQL = "Select * FROM tbl_linkstest WHERE display=yes AND cat=computer ORDER BY titletext ASC"

end if
 
'Set the Recordset
Set RSUser= Server.CreateObject("ADODB.RecordSet")
Set RSUser = Conn.Execute (SQL)
 
'Print the Recordset
RSUser.Movefirst
%>
     
    </p>

      <table width="100%">
<%Do While not RSUser.eof%>
<tr class="kwd4">

<td width="50%"><% Response.Write ("<a href=""" & "http://" & RSUser("url") & """ target=""_blank"">") & RSUser("titletext") & ("</a>") %></td>

<% RSUser.MoveNext
if RSUser.EOF then %>
<td width="50%">&nbsp;</td>
<tr class="kwd4">

<td width="100%" colspan="2">&nbsp;</td>
<% Exit Do
else %>
<td width="50%"><% Response.Write ("<a href=""" & "http://" & RSUser("url") & """ target=""_blank"">") & RSUser("titletext") & ("</a>") %></td>

<% RSUser.MoveNext
end if%>
</tr>
<tr class="kwd4">
<td width="100%" colspan="2">&nbsp;</td>
</tr>
<% Loop %>
</table>


Oh I am using an if statement for the SQL as I will add other areas later.  Basically what comes after cat= will change so

cat=computer
cat=shopping
cat=forums
cat=games

and so on.


Posted By: ub3rl337ch3ch
Date Posted: 19 June 2005 at 7:15pm
instead of
 
Set RSUser = Conn.Execute (SQL)

try

RSUser.open sql, Conn
 
 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net