Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2006, 02:03 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your syntax is incorrect, you have

rs.open [SQL], Connection 1, 1

it should be

rs.open [SQL], Connection, 1, 1

1 and 1 is your Cursor Type and Lock Type (respectively). You need these in place for .recordcount to work else it will return -1 no matter how many rows are actually returned.

For more information on the ADO open method you can check out this article:

http://www.w3schools.com/ado/met_rs_open.asp


--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old September 28th, 2006, 11:07 AM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

I GOT IT!! THANKS

Toni Burgess
misskaos99@yahoo.com
 
Old September 28th, 2006, 11:09 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

--EDIT You deleted your previous post right before this post processed! Glad you got it working though!

So, are you ready to smack yourself in the head and go DOH! (In the appropriate Homer Simpson Fashion)

This string: "SELECT * FROM CATEGORIES1" &_ "WHERE CategoryName ='" & strCategoryName & "'"

when its processed will literally translate into: SELECT * FROM CATEGORIES1WHERE CategoryName = '[value]'

your string should be this: "SELECT * FROM CATEGORIES1 " &_ "WHERE CategoryName ='" & strCategoryName & "'"
(notice the trailing space after the 1)

That should fix it up for you.


--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old September 28th, 2006, 01:50 PM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

LOL YES! You have noooo idea how much I appreciate your help! If I ever become a famous programmer I'll be sure to pay you your due credit! lol Thanks a bunch -- i see you got your yahoo icon up there lol, I think that's a big mistake for u--QUICKER FOR ME TO ASK FOR HELP lol jk, i will only bother u if absolutely necessary! lol thanks again!


Quote:
quote:Originally posted by dparsons
 --EDIT You deleted your previous post right before this post processed! Glad you got it working though!

So, are you ready to smack yourself in the head and go DOH! (In the appropriate Homer Simpson Fashion)

This string: "SELECT * FROM CATEGORIES1" &_ "WHERE CategoryName ='" & strCategoryName & "'"

when its processed will literally translate into: SELECT * FROM CATEGORIES1WHERE CategoryName = '[value]'

your string should be this: "SELECT * FROM CATEGORIES1 " &_ "WHERE CategoryName ='" & strCategoryName & "'"
(notice the trailing space after the 1)

That should fix it up for you.


--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
Toni Burgess
misskaos99@yahoo.com
 
Old September 28th, 2006, 02:17 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

If it was a bother for me to help people I wouldnt be here, all and all I am glad everything worked out for you.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old October 2nd, 2006, 11:32 AM
Authorized User
 
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to misskaos
Default

PURPOSE: Trying to populate a list box with values from a database.
*I have a program I am playing with and the next step I am on now is building a list box with the values from my table. i.e.: I want to implement all items in the list box, so that the user may perform queries off of the values found. i.e. go on table called Employees" I have a field in the Customers1 table named City.... so I'm trying to get all the cities of the customers into a listbox (without duplicates).

Thanks for all your time and patience, have a great day!

...>>>code<<<...
unction QueryCityResults()



                    rs.open "SELECT * " & _
                    "FROM EMPLOYEES" _
                    ,ConnectionString


                     out = ""

                     If Not rs.EOF Then

                             'out = out & "<TR>" & vbCrLf

                             For i = 0 To rs.Fields.Count - 1
                                 out = out & "<TD class=""header"">" & _
                                         rs.Fields(i).name & _
                                             "</TD>" & vbCrLf
                             Next

                             'out = out & "</TR>" & vbCrLf
                        End If
...>>>code<<<...
...>>>code<<<...
That's the function and here is where I am calling it:

<%
If strCityName ="Midway Park" Then
%>

<HTML>
<HEAD>

<TITLE>Upload Table CUSTOMERS</TITLE>
    <style>
     .header {
        font: bold 12pt sans-serif;
    color: purple;
     }

     td {
        font: 10pt sans-serif;
    color: blue;
     }
    </style>
</HEAD>
<H1>VIEWING CUSTOMERS LIVING IN MIDWAY PARK</H1>
<BODY>
<P>
<FORM NAME = "frmClick" ACTION="Tables2.asp">
<INPUT TYPE="SUBMIT" NAME="CHOOSE" VALUE="CHANGE TABLE" onClick = "Tables2.asp">
</FORM>
<FORM NAME = "frmClick" ACTION="insertcust.asp">
<INPUT TYPE="SUBMIT" NAME="CHOOSE" VALUE="INSERT CUSTOMER" onClick = "insertcust.asp">
</FORM>
<FORM NAME = "frmClick" ACTION="custdeletecustid.asp">
<INPUT TYPE="SUBMIT" NAME="CHOOSE" VALUE="DELETE CUSTOMER" onClick = "custdeletecustid.asp">
</FORM>
<FORM NAME = "frmClick" ACTION="performquery.asp">
<INPUT TYPE="SUBMIT" NAME="CHOOSE" VALUE="PERFORM QUERY" onClick = "performquery.asp">
</FORM>
    <table border="1">
     <%= GetCustomerCity %>
    </table>

</BODY>

</HTML>

<%
End If
%>

Here is the ERROR msg:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/tburgess2/viewbycustid.asp, line 34, column 14
"WHERE (CITY="Midway Park")" _
-------------^

And I'm not sure what's wrong with that line, I've tried changing it several different times to no avail. But even when I get it to working it still only shows one field value in the options select.


Toni Burgess
misskaos99@yahoo.com
 
Old October 2nd, 2006, 11:54 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ok first SQL string delimters are ' not " so you always always have to use ' when you pass a string into a SQL Query so:

WHERE City = 'Midway Park'

To return unique cities you need:

SELECT DISTINCT city from table

I dont see any code with a WHERE clause so i am not sure what is up but here is the code you would use to populate a listbox:

<%
'Return your query here
%>
<select id="something">
<% While not rs.eof%>
<option value="<%=rs("valuecolumn")%>"><%=rs("textColumn") %></option>
<%wend%>
</select>
<%
'Dispose of your objects here
%>

hth


--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving data using form misskaos Classic ASP Basics 3 October 27th, 2006 03:16 PM
Saving Form Data Earl Hickey ASP.NET 1.0 and 1.1 Basics 5 July 25th, 2006 01:10 PM
Auto-populate table data into form jeff394 Access VBA 2 April 19th, 2006 02:55 PM
Coding for data input from one form to 2 tables... dgarcia1128 Access VBA 1 February 19th, 2004 12:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.