View previous topic :: View next topic |
Author |
Message |
TrvlOrm -
Joined: 09 Jun 2004 Posts: 25
|
Posted: Fri Jun 18, 2004 7:00 am Post subject: ASP link back to database |
|
|
I am having great difficulty in these asp scrips, using VBscript and JavaScript.
I have 4 files that all need to be linked together.
The first file "Books.html" - needs to search for a Book title, author or ISBN number from a Access database called "Books.mdb". When the user clicks Submit from the "Books.html" file (after inputting info in a text box and clicking the required box to define Title, Author or ISBN), the information is then filtered through "Books.asp" file and "CreateTable.asp" file.
<PLEASE SEE MY FILES and coding below this message, didn't know how to attach files - files below: Books.asp; Books.inc; Books.html and CreateTable.asp. Not shown is Books.mdb Access database file.
My problem is this: I cannot get the script in the Books.asp file to only bring up certain information pertaining to that in my search box from the "Books.html" file. What happens, is a) I get a error message when I try and debug it or b) the full table comes up.
HELP !
I am using Abysse web server under http://localhost port8080.
Can anyone please help.. Any feedback most appreciated. My personal e-mail is ksorman@shaw.ca for any step by step instructions you can offer.
Thank you so much.
PS - yah, you guessed it, this is a URGENT request too. :)
[code]"BOOKS.ASP file"[/code]
[code]
<HTML>
<!--#INCLUDE FILE="Books.inc" -->
<!--#INCLUDE FILE="ADOVBS.inc" -->
<!--#INCLUDE FILE="CreateTable.asp" -->
<HEAD>
<TITLE>Accessing a Data Store using DSN (Data Source Name) with Active Server Pages </TITLE>
</HEAD>
<BODY>
<%
Dim objConn
Dim objRec
Dim CheckISBN
Dim CheckTitle
Dim CheckAuthor
Dim SearchString
Dim found
objConn.Open strConnect
objRec.Open "Titles",strConnect,adOpenStatic,adLockReadOnly,adCmdTable
objRec.MoveFirst
Response.Write CreateTable(objRec)
found=0
CheckISBN=Request.Form("chkISBN")
CheckTitle=Request.Form("chkTitle")
CheckAuthor=Request.Form("chkAuthor")
SearchString=Request.Form("txtSearch")
Set objConn=Server.CreateObject("ADODB.Connection")
Set objRec=Server.CreateObject("ADODB.RecordSet")
objConn.Open strConnect
objRec.Open "Titles",strConnect,adOpenStatic,adLockReadOnly,adCmdtable
objRec.MoveFirst
If CheckISBN = "ByISBN" Then
objRec.Find "ISBN= '"& Request.Form("txtSearch") & "'"
If Not objRec.EOF Then
found=1
Response.Write objRec("ISBN")
Response.Write " "
Response.Write objRec("Price")
Response.Write " "
Response.Write objRec("Title") & "<BR>"
End if
End if
If CheckTitle = "ByTitle" Then
objRec.Find "Title= '"& Request.Form("txtSearch") & "'"
If Not objRec.EOF Then
found=1
Response.Write objRec("ISBN")
Response.Write " "
Response.Write objRec("Price")
Response.Write " "
Response.Write objRec("Title") & "<BR>"
End if
End if
If CheckAuthor = "ByAuthor" Then
objRec.Filter = "Author= '"& Request.Form("txtSearch") & "'"
While Not objRec.EOF
If objRec("Author") = SearchString Then
found=1
Response.Write objRec("ISBN")
Response.Write " "
Response.Write objRec("Price")
Response.Write " "
Response.Write objRec("Title") & "<BR>"
End if
objRec.MoveNext
Wend
If found=0 Then
Response.Write "Record Not Found"
End if
End if
objRec.Close
objConn.Close
Set objRec=Nothing
Set objConn=Nothing
</BODY>
</HTML>
[/code]
[code]BOOKS.INC file[/code]
[code]
<HTML>
<HEAD>
<TITLE>Location specific records in a database, with DSN and Active Server Pages </TITLE>
</HEAD>
<BODY>
<%
strConnect = "Driver={Microsoft Access Driver (*.mdb)};DBQ=c:\inetpub\wwwroot\K_Orman\Books.mdb;"
%>
</BODY>
</HTML>
[/code]
[code]BOOKS.HTML file[/code]
<HTML>
<HEAD>
<TITLE> Location Specifc Records - Active Server Pages, Connecting to DSN - PART 3</TITLE>
</HEAD>
<BODY>
<FORM NAME="frmsearch" ACTION="Books.asp" METHOD="Post">
<H3> Please enter the Title, the Author, or the ISBN number of the book(s) you wish to search for: </H3>
<INPUT TYPE="text" NAME="txtSearch"><BR>
Search by: <BR>
<INPUT TYPE="checkbox" NAME="chkTitle" VALUE="ByTitle"> Title <BR>
<INPUT TYPE="checkbox" NAME="chkAuthor" VALUE="ByAuthor"> Author <BR>
<INPUT TYPE="checkbox" NAME="chkISBN" VALUE="ByISBN"> ISBN <BR><BR><BR>
<INPUT TYPE="submit" NAME="cmdSearch" VALUE="Search"><BR>
<INPUT TYPE="Reset" NAME="cmdreset" VALUE="Reset">
</FORM>
</BODY>
</HTML>
[/code]
[code]CREATETABLE.asp file[/code]
[code]
<HTML>
<HEAD>
<TITLE> Active Server Pages - Data Name Source </TITLE>
</HEAD>
<BODY>
<%
Function CreateTable(objRecordset)
Dim fldField
Dim strTable
strTable = "<TABLE BORDER=2>" & "<TR ALIGN=CENTER>"
For Each fldField in objRecordset.Fields
strTable = strTable & "<TD>" & fldField.Name & "</TD>"
Next
strTable = strTable & "</TR>"
While not objRecordset.EOF
strTable = strTable & "<TR ALIGN=CENTER>"
For Each fldField in objRecordset.Fields
strTable= strTable & "<TD>" & fldField.Value & "</TD>"
Next
strTable= strTable & "</TR>"
objRecordset.MoveNext
Wend
strTable = strTable & "</TABLE>"
CreateTable = strTable
End Function
%>
</BODY>
</HTML>
[/code]
[/quote][/code] THANK YOU SO MUCH..... |
|
Back to top |
|
|
masa -
Joined: 05 Apr 2004 Posts: 182 Location: Hong Kong
|
|
Back to top |
|
|
TrvlOrm -
Joined: 09 Jun 2004 Posts: 25
|
Posted: Fri Jun 18, 2004 6:22 pm Post subject: still not working |
|
|
I got all of the coding from a scripting book and wrote it all myself.
Can any one help?
Thanks, |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Jun 19, 2004 3:07 pm Post subject: Re: ASP link back to database |
|
|
TrvlOrm,
What was the exact error message you've got? _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
TrvlOrm -
Joined: 09 Jun 2004 Posts: 25
|
Posted: Sat Jun 19, 2004 8:48 pm Post subject: still need help please |
|
|
After fixing a few things in the above coding for all three files. This is the error I now get...
Any ideas?
[quote]
Microsoft VBScript compilation error- Error '800a0400'
Expected statement
/K_Orman/Books.asp, line 62
End if
^
[/quote]
This is in the Books.asp file.. Here is the new code:
[code]
<HTML>
<!--#INCLUDE FILE="Books.inc" -->
<!--#INCLUDE FILE="ADOVBS.inc" -->
<!--#INCLUDE FILE="CreateTable.asp" -->
<HEAD>
<TITLE>Books.asp - Accessing a Data Store using DSN (Data Source Name) with Active Server Pages </TITLE>
</HEAD>
<BODY>
<%
Dim objConn
Dim objRec
Dim CheckISBN
Dim CheckTitle
Dim CheckAuthor
Dim SearchString
Dim found
found=0
CheckISBN=Request.Form("chkISBN")
CheckTitle=Request.Form("chkTitle")
CheckAuthor=Request.Form("chkAuthor")
SearchString=Request.Form("txtSearch")
Set objConn=Server.CreateObject("ADODB.Connection")
Set objRec=Server.CreateObject("ADODB.RecordSet")
objConn.Open strConnect
objRec.Open "Titles",objConn,0,1,2
objRec.MoveFirst
If CheckISBN = "ByISBN" Then
objRec.Find "ISBN= '"& Request.Form("txtSearch") & "'"
If Not objRec.EOF Then
found=1
Response.Write objRec("ISBN")
Response.Write " "
Response.Write objRec("Price")
Response.Write " "
Response.Write objRec("Title") & "<BR>"
End if
End if
If CheckTitle = "ByTitle" Then
objRec.Find "Title= '"&Request.Form("txtSearch") & "'"
While Not objRec.EOF
found = 1
Response.Write objRec("ISBN")
Response.Write " "
Response.Write objRec("Price")
Response.Write " "
Response.Write objRec("Title") & "<BR>"
End if
End if
If CheckAuthor = "ByAuthor" Then
objRec.Filter = "Author = '"& Request.Form("txtSearch") & "'"
While Not objRec.EOF
If objRec("Author") = SearchString Then
found=1
Response.Write objRec("ISBN")
Response.Write " "
Response.Write objRec("Price")
Response.Write " "
Response.Write objRec("Title") & "<BR>"
End if
objRec.MoveNext
Wend
If found=0 Then
Response.Write "Record Not Found"
End if
End if
objRec.Close
objConn.Close
Set objRec=Nothing
Set objConn=Nothing
%>
</BODY>
</HTML>
[/code] |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Jun 21, 2004 2:58 pm Post subject: Re: still need help please |
|
|
TrvlOrm wrote: | Quote: |
Microsoft VBScript compilation error- Error '800a0400'
Expected statement
/K_Orman/Books.asp, line 62
End if
^
|
|
The error is self-explicit. In line 62, you have an extra End if that doesn't match with an if statement. Remove it and retry the script. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
TrvlOrm -
Joined: 09 Jun 2004 Posts: 25
|
Posted: Mon Jun 21, 2004 6:37 pm Post subject: New error |
|
|
Fixed the code, now have new error in Books.asp.
See all of Books.asp code above.
[quote]
Microsoft VBScript compilation error- Error '800a03fa'
Expected 'Wend'
/K_Orman/Books.asp, line 15
Response.WriteBlock(8)
----------------------^[/quote]
What do I do here to fix this? Yes, I'm new at this coding thing. Any help much appreciated - but this is URGENT TO.
Thanks. |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Jun 24, 2004 4:12 pm Post subject: Re: New error |
|
|
TrvlOrm,
One more time, the error code means that you have a syntax error. Please review the syntax of your code and if you're new to ASP, read a tutorial about it to know the basics of VBScript syntax.
(by the way, the error means that there is a While loop without a matching Wend to close the loop.) _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
TrvlOrm -
Joined: 09 Jun 2004 Posts: 25
|
Posted: Thu Jun 24, 2004 9:04 pm Post subject: Re: New error |
|
|
Thanks for taking so long to reply, I see 3 days. Is that norm?
Anyways, never mind it has been fixed.
[quote="aprelium"]TrvlOrm,
One more time, the error code means that you have a syntax error. Please review the syntax of your code and if you're new to ASP, read a tutorial about it to know the basics of VBScript syntax.
(by the way, the error means that there is a [b]While [/b]loop without a matching [b]Wend [/b]to close the loop.)[/quote] |
|
Back to top |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Thu Jun 24, 2004 9:08 pm Post subject: |
|
|
3 days is the norm for problems unrelated to Abyss. You can't expect the developers of a webserver to sit and solve the problems in your code for you... |
|
Back to top |
|
|
|