SQL,Multifunction,form,basic,navigation,table
Quick Search for:  in language:    
SQL,Multifunction,form,basic,navigation,table
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 143,093 lines
 Jobs: 168 postings

 
Sponsored by:

 

You are in:

 
Login


 

 


Latest Code Ticker for ASP/ VbScript.
Outlook Mail Backup 1.2
By Maxim Kazitov on 10/24


A Socket Component based on Winsock, TCP/IP and client/server communication
By Joyce Flemmings on 10/24


An EMail Component for SMTP mailservers
By Joyce Flemmings on 10/24


A Comport serial communications (modem, direct serial cable, or other comport communications) tool
By Joyce Flemmings on 10/24


A self modifying code sample
By Rowen Bankx on 10/24


A script to list all print jobs on a (remote) print server
By Rowen Bankx on 10/24


A nice DNS/WINS script: Change DNS and WINS on remote computers. Based on WMI
By Rowen Bankx on 10/24


A WMI example: reboot a (remote) computer
By Rowen Bankx on 10/24


aspAccessEditor
By Dennis Pallett on 10/23


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

All_Form.ASP

Print
Email
 
VB icon
Submitted on: 2/19/2000
By: Found on the World Wide Web 
Level: Beginner
User Rating: By 8 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 32690 times.
 
 
     Multi-function form for basic navigation, table editing, and recordset paging. This example includes code to dynamically build an SQL UPDATE command based on changed items on the current record. http://adozone.cnw.com/default.htm
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    '**************************************
    ' Name: All_Form.ASP
    ' Description:Multi-function form for ba
    '     sic navigation, table editing, and recor
    '     dset paging. This example includes code 
    '     to dynamically build an SQL UPDATE comma
    '     nd based on changed items on the current
    '     record.
    http://adozone.cnw.com/default.htm
    ' By: Found on the World Wide Web
    '**************************************
    
    <% Option Explicit %>
    <% Response.Expires=0 %>
    <HTML>
    <HEAD></HEAD>
    <BODY BGColor=White Text=Black>
    <STYLE>
    	.btn {Width:100%}
    </STYLE>
    <% 	
    Dim Page				' Local var For page #
    Dim cn				' Connection object
    Dim rs				' Recordset object
    Dim Action			' Button pressed
    Dim PageSize		' How far To page
    Dim UpdSQL, MySQL		' String To hold SQL 
    Dim i					' Loop counter
    Dim item, value	' Used To retrieve changed fields
    Dim issueUpdate	' After Save button press, any changes to make?
    Action = Request.Form("NavAction")
    if Request.Form("Page") <> "" Then
    	Page = Request.Form("Page")
    Else
    	Page = 1
    End if
    if Request.Form("PageSize") <> "" Then 
    	PageSize = Request.Form("PageSize")
    Else
    	PageSize = 5
    End if
    		Set cn = Server.CreateObject("ADODB.Connection")
    		cn.Open Application("guestDSN")
    		' Get initial recordset
    		Set rs = Server.CreateObject("ADODB.Recordset")
    		MySQL = "SELECT * FROM AUTHORS"
    rs.PageSize = PageSize
    rs.Open MySQL, cn, adOpenKeyset, adLockOptimistic
    		Select Case Action
    			Case "Begin"
    	Page = 1
    			Case "Back"
    		if (Page > 1) Then 
    			Page = Page - 1
    		Else 
    			Page = 1
    			End if
    		rs.AbsolutePage = Page
    			Case "Forward"
    		if (CInt(Page) < rs.PageCount) Then 
    			Page = Page + 1
    		Else 
    			Page = rs.PageCount 
    			End if
    		rs.AbsolutePage = Page
    			Case "End"
    		rs.AbsolutePage = rs.PageCount 
    	Case "Save"
    		' Grab the proper record, Then update
    		' This routine is hard coded For AU_ID as the key field. 
    		' To alter this to work With another DB Table you will need to 
    		' Use the proper primary key instead of AU_ID.
    		rs.Close
    		MySQL = "SELECT * FROM AUTHORS WHERE au_id = '" & Request.Form("Au_id") & "'"
    		rs.MaxRecords = 1
    		rs.Open MySQL, cn, adOpenStatic, adLockOptimistic
    		UpdSQL = "UPDATE AUTHORS "
    		issueUpdate = False
    		For i = 0 To (rs.Fields.Count - 1)
    			item = rs.Fields(i).Name
    			value = Request.Form(item)
    			' Only update items that have changed
    			if (rs(i) <> value) Then
    				if issueUpdate = False Then 
    					UpdSQL = UpdSQL & "SET "
    				Else
    					UpdSQL = UpdSQL & ","
    				End if
    				issueUpdate = True
    				Select Case VarType(rs.Fields(i))
    					' Determine datatype For proper SQL UPDATE syntax
    					' NOTE: Not all data types covered
    					Case vbString, vbDate
    						UpdSQL = UpdSQL & item & "='" & value & "'"
    					Case vbNull
    					Case vbInteger
    						UpdSQL = UpdSQL & item & "=" & value
    					Case vbBoolean
    						if value Then
    							UpdSQL = UpdSQL & item & "= 1"
    						Else
    							UpdSQL = UpdSQL & item & "= 0"
    						End if
    				End Select
    			End if
    		Next 
    		UpdSQL = UpdSQL & " WHERE au_id = '" & Request.Form("Au_id") & "'"
    		if issueUpdate Then
    			cn.Execute UpdSQL
    			Set rs = cn.Execute(MySQL)
    			End if
    			Case "New"
    		' response.write "New"
    				rs.AddNew
    			Case "Bookmark"
    				Session("myBookMark") = rs.BookMark
    			Case "Goto"
    				if Not IsNull(Session("myBookMark")) Then
    					rs.BookMark = Session("myBookMark")
    				End if
    			Case Else
    			rs.MoveFirst
    		End Select
    %>
    <CENTER>
    <!-- 2 Column Table -->
    <!-- 1 Column For Data, 1 for Controls -->
    <TABLE Align=Center border=1 BGColor=Navy
    BorderColorDark=Navy BorderColorLight=Aqua BorderColor=Blue>
    <!-- Table Header -->
    <TH Colspan=2>
    <FONT Color=White Size=+2><CENTER>Navigating Example</CENTER></FONT>
    </TH>
    <!-- Main Table Content -->
    <TR><TD>
    <!-- Nested Table 1 -->
    <!-- Author Detail -->
    <FORM Action=all_form.asp Method="POST">
    <TABLE Align=Left BORDER=0 BGColor=Gray Text=White>
    	<%
    	For i = 0 To rs.Fields.Count - 1
    		%>
    		<TR><TD><B><%= rs.Fields(i).Name %></B></TD>
    		<TD><INPUT Type=text Name="<%= rs.Fields(i).Name %>" Value="<%= rs(i) %>"></TD>
    </TR>
    		<%
    	Next 
    	%>
    </TABLE>
    </TD>
    <TD BGColor=Black Width=100>
    	<!-- Nested Form 2 -->
    		<!-- Persisted Values -->
    	<INPUT Type="Hidden" Name="PageSize" Value="1">
    	<INPUT Type="Hidden" Name="Page" Value="<%= Page %>">
    	<!-- Navigation Buttons -->
    	<INPUT TYPE="Submit" Name="NavAction" Value="Begin" Class=Btn><BR>
    	<INPUT TYPE="Submit" Name="NavAction" Value="Back" Class=Btn><BR>
    	<INPUT TYPE="Submit" Name="NavAction" Value="Forward" Class=Btn><BR>
    	<INPUT TYPE="Submit" Name="NavAction" Value="End" Class=Btn><P>
    	<INPUT TYPE="Submit" Name="NavAction" Value="Save" Class=Btn><BR>
    	<INPUT TYPE="Submit" Name="NavAction" Value="New" Class=Btn><P>
    	<INPUT TYPE="Submit" Name="NavAction" Value="Bookmark" Class=Btn><BR>
    	<INPUT TYPE="Submit" Name="NavAction" Value="Goto" Class=Btn><P>
    </TD>
    </TR>
    </TABLE>
    </FORM>
    <P>
    <!-- Floating Frame -->
    	<IFRAME width=70% height=180 src="list.asp?auid=<%= rs( </Include/code.asp?source=/ado/samples/list.asp?auid=<%= rs(>"au_id") %>" FrameBorder=1 Scrolling=No>
    	<FRAME width=70% height=180 src="list.asp?auid=<%= rs( </Include/code.asp?source=/ado/samples/list.asp?auid=<%= rs(>"au_id") %>">
    	</IFRAME> 	
    </CENTER>
    </BODY>
    </HTML>


Other 31 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
6/1/2000 12:25:31 AM:sean
how do I just do basic record 
navigation...can it be done without 
paging...when I hit the buttons, the 
asp page reloads/executes the original 
SQL so my NEXT button will always give 
you the second record...I can't get it 
to stop reloading and resetting itself 
to the first record...help.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/1/2000 12:27:06 AM:sean
I have next and prev buttons on a form, 
having trouble navigating through a 
recordset - the page reloads eachtime 
and resets the form so that NEXT will 
always give you the second record - can 
I get around this without paging each 
record...( I hope so...) Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.