navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Improving my add.asp page

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Improving my add.asp page
Page: [1]
 
crosscreek

 

Posts: 107
Joined: 2/5/2008
Status: offline

 
Improving my add.asp page - 3/11/2008 0:31:40   
I am trying to improve my asp page that will add dogs to my database.

If someone submits a blank form then they get a "must type something in"
If someone trys to add a duplicate, then gets "dog already in database"
If they type in a dog's name that neither choices above then the dogs added.

Now I am able to do the 1st two, but can't get the code to add the dog if the first two codes are false.

This is that I have so far...Now I will fix it for SQL injection, I just want to get it to work first.

Dim objrs, bolalreadyexists
If Request.form("doggy") = "" OR Request.form("doggy") = " " Then
Response.Write ("No Search Text Entered! YOu must type a name.")
Response.Write ("<a href='adddog.htm'> Click to go back to the Add dog Page page")
Else
bolalreadyexists = false
Set objrs = Server.CreateObject("ADODB.Recordset")
objRS.open "tbldog", myConn, , adlockoptimistic, adcmdtable
Do while not (objrs.eof OR bolalreadyexists)
If (strcomp(LCase(objrs("name")), request.form("doggy"), vbBinaryCompare) = 0) then
Response.write "This dog has already been entered. Please go back to enter a new dog in or click below to go to the pedigree page."
Response.Write "<a href=""pedigree.asp?id="&objRS("ID")&""">" & objRS("name") & "</a>"
bolalreadyexists = true
End if
objrs.movenext
Loop

If not bolalreadyexists then
objRS.AddNew
objRS("name") = Request.form("doggy")
objRS.Update
Response.write "you have added the dog"
End if

objrs.close
set objrs = nothing

End if

myConn.close
Set myConn = nothing


HELP!



< Message edited by crosscreek -- 3/11/2008 1:18:22 >
crosscreek

 

Posts: 107
Joined: 2/5/2008
Status: offline

 
RE: Improving my add.asp page - 3/11/2008 1:50:35   
quote:

Response.Write "<a href=""pedigree.asp?id="&objRS("ID")&""">" & objRS("name") & "</a>"


For some reason it didn't like this. It's a hyperlink to the duplicated dog in the database. Once I took that out...worked great.
Thanks
Helena

(in reply to crosscreek)
rdouglass

 

Posts: 9167
From: Biddeford, ME USA
Status: offline

 
RE: Improving my add.asp page - 3/11/2008 14:31:00   
quote:

&""">


I think it's right in that mess. I hate using double double quotes in ASP - I always get lost.:) :)

That's why I either use just apostrophes in links or if I need them as in a JavaScript, I'll use CHR(034) instead as in:

Response.Write "<a href="& CHR(034) & "pedigree.asp?id="&objRS("ID")& CHR(034) & ">" & objRS("name") & "</a>"

Once you get used to seeing it, it's a whole lot easier IMO.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to crosscreek)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Improving my add.asp page
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts