Wrox Programmer Forums
|
BOOK: Beginning ASP.NET Databases Also see the forum ASP Databases for more general discussions of ASP database issues not directly related to these books.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Databases 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 July 19th, 2004, 01:15 AM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default A little ASP help pls?

I am having trouble getting some simple code to work. I figure I can look at it for another million hours and maybe find the problem, or just run it past one of the experts and see what you come up with. It's probably something silly.

Here it is, it's almost letter for letter of "Beginning ASP Databases" page 389:



<body>
Update a puppy

<%
Dim strSQL
Dim adCmdText

adCmdText = 1

If Len(Request.Form("FormAction")) = 0 Then

Set objRS = Server.CreateObject("ADODB.Recordset")
objRs.Open "Select name from pups","DSN=XXXXXXX; User ID=XXXXXX; Password=XXXXXXX"
%>

<FORM ACTION=update.asp METHOD=post NAME=frmDisplay
<INPUT TYPE=hidden NAME=FormAction VALUE=Step2>
<TABLE>
<TR>
<TD COLSPAN=2> Select a puppy to update</TD>
</TR>
<TR>
<TD>Puppy Name</TD>
<TD><SELECT NAME=cboname>
<%
Do While Not objRS.EOF
%>

<OPTION VALUE="<%=objRS("name")%>">
<%=objRS("name")%></OPTION>

<%
objRS.MoveNext

Loop

objRS.Close
Set objRS = Nothing

%>

</SELECT></TD>
</TR>
<TR>
<TD HEIGHT=60> <INPUT TYPE=submit NAME=btnSubmit VALUE=Submit> </TD>
</TR>
</TABLE>
</FORM>

<%
ElseIf Request.Form("FormAction") = "Step2" Then

strSQL = "Select * from pups where name = '" & _
CStr(Request.Form("cboname")) & "'"
Set objRS = Server.CreateObject("ADODB.Recordset")
objRs.Open strSQL,"DSN=XXXXXXXXXXXX; User ID=XXXXXXXXX; Password=XXXXXXXXXX"
%>

<FORM ACTION=update.asp METHOD=post NAME=frmUpdate>
<INPUT TYPE=hidden NAME=FormAction VALUE=Step3>
<INPUT TYPE=hidden NAME=txtname
VALUE="<%=objRS("name")%>">
<TABLE>
<TR>
<TD>Puppy Name</TD>
<TD> <%=objRS("name")%></TD>
</TR>
<TR>
<TD NOWRAP>Breeder</TD>
<TD><INPUT TYPE=text NAME=txtbreeder Size=25
VALUE=<%=objRS("breeder")%>> </TD>
</TR>
<TR>
<TD HEIGHT=60>
<INPUT TYPE=button NAME=btnSubmit VALUE=Submit> </TD>
</TR>
</TABLE>
</FORM>

<%
objRS.Close
Set objRS = Nothing
%>

<SCRIPT LANGUAGE=vbscript>
Sub btnSubmit_OnClick()
Call frmUpdate.submit()
End Sub
</SCRIPT>

<%
ElseIf Request.Form("FormAction") = "Step3" Then

strSQL = "Update pups Set " & _
"breeder = " & _
CStr(Request.Form("txtbreeder")) & ", " & _
"WHERE name = '" & _
CStr(Request.Form("txtname")) & "'"

Set obConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=XXXXXXXXX; User ID=XXXXXXX; Password=XXXXXXX"

Set objCmd = Server.CreateObject("ADODB.Command")

Set objCmd.ActiveConnection = objConn
objCmd.CommandText = strSQL
objCmd.CommandType = adCmdText

objCmd.Execute

Response.Write "This was updated " & _
"now it's done.<P>"
Response.Write strSQL

Set objCmd = Nothing
objConn.Close
Set objConn = Nothing

End If
%>
</body>
 
Old July 19th, 2004, 08:06 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Your problem is here:
<FORM ACTION=update.asp METHOD=post NAME=frmDisplay
You're missing a '>'.

BTW.... Why on earth are you posting in the feedback forum?

Snib

<><
 
Old July 19th, 2004, 08:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Might I suggest that you post this in the 'Beginning ASP Databases' forum under 'Books', not the site feedback forum :)

Chris

There are two secrets to success in this world:
1. Never tell everything you know

I'd also like to suggest that I read all my mail before replying to something





Similar Threads
Thread Thread Starter Forum Replies Last Post
pls help can ASP display images [email protected] ASP.NET 1.0 and 1.1 Basics 3 August 12th, 2006 02:31 PM
Sendmail, Application - ASP.NET1.1-Urgent..Pls ! Abins ASP.NET 1.0 and 1.1 Basics 1 February 21st, 2006 08:06 AM
Crystal reports & ASP - Runtime Error - Pls Help Prasad_Tina Classic ASP Basics 0 January 21st, 2005 10:53 AM





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