Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 15th, 2006, 02:08 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error on the Example shown on the book

Hi, there?
I'm trying to run the example code from the wrox book called, "Beginning ASP databases".

In chapter 5, there is an example code as follows and just try to copy and to paste running this code I got into error message.

The error message is

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
ODBC driver does not support the requested properties.

From the sql text line, SQLtxt = "Select * FROM Items WHERE ItemVendor = " & vVendor & ";"
if I delete vVendor the error message disappear.
Is that because vVendor set up as QueryString value??? How do I make this code working?


<html>
<head>
<title>Chapter_05_MoreRS_Exercise_3_Vendor_Items_R esponse</title>
</head>
<body>
<h2>Chapter 05 MoreRS Exercise 3</h2>
<h3>Exercise #3 Vendor Items Response</h3>
<%
  dim vVendor
  vVendor = Request.QueryString("lstVendors")

  dimDim oRSi
  set oRSi=server.CreateObject("ADODB.Recordset")
  SQLtxt = "Select * FROM Items WHERE ItemVendor = " & vVendor & ";"
  oRSi.Open sqltxt, "DSN=clothier"
  oRSi.movef.MoveFirst

  Response.Write "<TABLE BORDER=1><TR>"
  ' Header row
  For Each oHeader in oRSi.Fields
    Response.Write "<th>" & oHeader.name & "</th>"
  Next
  Response.Write "</TR><TR><TD>"
  ' Data rows
  Response.Write oRSi.GetString(,,"</td><td>","</TD></TR><TR><TD>")
  Response.Write "</TD></TR></Table>"
  oRSi.Close
  Set oRSi=nothing
%>
</body>
</html>


Reply With Quote
  #2 (permalink)  
Old January 15th, 2006, 04:19 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
quote:Is that because vVendor set up as QueryString value???
Yeah, it looks like that's the problem, so vVendor never gets a value.

Maybe you're not supposed to request this page directly? Instead, look for a previous page with a form and at least a drop-down list (or other HTML form control) called lstVendors that submits to this page...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old January 16th, 2006, 12:36 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your advice, Imar.
I did use Drop-down list and actually I'm trying to run the code from Excercise.
But I'm getting the error message and any other advice??

Reply With Quote
  #4 (permalink)  
Old January 16th, 2006, 03:16 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi again,

In that case, can you post the complete code for both pages?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old January 16th, 2006, 03:36 AM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for so much for your help again.

Here is the code where it calls the data from DB for the select option.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="949"%>

<HTML>
<Head>
<TITLE> </TITLE>
</Head>
<body>
<%
    Dim objRS
    Set objRS = Server.CreateObject ("ADODB.Recordset")

    sqlstr = "SELECT xxx from xx ORDER BY xx ASC"

    objRS.Open sqlstr, dbCon, 1

    objRS.MoveFirst
%>
<form method="get" action="xxxxx.asp">
<p><Select Name="DealerCode" Size="6">
<%
    Do While NOT objRS.EOF
        Response.Write "<Option Value='"& objRS("xxx") & "'>"
        Response.Write objRS("xxxx") & "</Option>"
        objRS.MoveNext
    Loop

    objRS.Close
    Set objRS = Nothing
%>
</SELECT> </P>
<p><INPUT TYPE="submit"> </P>
</form>
</body>
</html>

And the xxx.asp is as follows,

<%@LANGUAGE="VBSCRIPT" CODEPAGE="949"%>

<HTML>
<HEAD>
<TITLE>:::</TITLE>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
    Dim sDealer
    sDealer = Request.QueryString ("DealerCode")

    sqlstr = "SELECT x_xxfrom xxx WHERE xxxxxx= '" & sDealer & "';"

    rs.Open sqlstr, dbCon, 3, 3
    rs.MoveNext

    if rs.EOF = false then

%>



<%
else
    Response.Write "<TABLE BORDER=1><TR><TD ALIGN=CENTER>"
    Response.Write rs.GetString(,,"</TD><TD ALIGN=CENTER>","</TD></TR><TR><TD ALIGN=CENTER>","-unknown-")
    Response.Write "</TD></TR></TABLE>"

    rs.Close
    set rs = nothing

End if

%>
</BODY>
</HTML>
Reply With Quote
  #6 (permalink)  
Old January 16th, 2006, 03:16 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hmm can't see any obvious error...

On the first page, do you see items in the drop-down list before you click the submit button?

To diagnose the second page, make the following change and post the output to this thread:

sqlstr = "SELECT Dealer_Code from tblDealerInfo WHERE Dealer_Code = '" & sDealer & "';"

   Response.Write("Sql is " & sqlstr)
   Response.End()
   rs.Open sqlstr, dbCon, 3, 3
   rs.MoveNext

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #7 (permalink)  
Old January 16th, 2006, 09:05 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello, Imar, yes, I am able to read the data for the select option.

Okay, it displays.. "Sql is SELECT xxxx from xxxx WHERE xxxx = 'xxxx';" but it doesn't the display the result of the select query.
How come it doesn't display the query table?
Reply With Quote
  #8 (permalink)  
Old January 17th, 2006, 03:49 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Right, I thought it was still displaying an error like "ODBC driver does not support the requested properties" so I was looking for a reason for that error.

Apparently, something changed somehow for the better, without you telling us.

Anyway, look at this:

 rs.Open sqlstr, dbCon, 3, 3
 rs.MoveNext

 if rs.EOF = false then

You select one record, then do a MoveNext (effectively changing the recordset's pointer to the second record) and then check for EOF. Since there was only one record, EOF will now be True and the record won't be displayed.

Whenever you open a recordset in ADO, it's ready for use; there is no need to use MoveFirst or MoveNext first. So the fix is:

 rs.Open sqlstr, dbCon, 3, 3
<s> rs.MoveNext</s>
 if rs.EOF = false then


Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #9 (permalink)  
Old January 17th, 2006, 10:52 PM
Authorized User
 
Join Date: Nov 2005
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello, Imar?
The problem got solved and You're the man!!
Thank you so much,
Best Regards,
Tarzannn.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
results shown by query Vince_421 Access 1 February 4th, 2007 12:45 PM
Associative arrays not shown at book brasilino BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 December 16th, 2006 08:51 AM
Error: Subreport could not be shown on VB 2005 yandisophian Visual Basic 2005 Basics 0 October 12th, 2006 08:17 PM
How to verify if form is shown pavel VB How-To 3 October 1st, 2004 01:10 AM
Element value to be shown only once...HOW? suri XSLT 2 August 10th, 2004 10:51 AM



All times are GMT -4. The time now is 10:18 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.