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 December 17th, 2011, 04:39 PM
Authorized User
 
Join Date: Aug 2011
Posts: 34
Thanks: 1
Thanked 1 Time in 1 Post
Default Create form to update server tables

Need help with displaying current data from tables and then submit update.

Current form:
Code:
strSQL = "select server.server_name, server.status, review.serverowner from server, review where Server.SERVER_NAME = review.SERVER_NAME and Server.SERVER_NAME = '" & strComputer &"'" (I use a query.string here that does bring over the correct server_name)
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn
Using above info, I populate a form. I then use another record set to give options for update options for form using a dropdown box created from a db table:
Code:
Set objRS4 = Server.CreateObject("ADODB.Recordset")
strSQL4 = "SELECT * FROM Options WHERE STable='server' AND SColumn='Status'" 
objRS4.Open strSQL4, objConn
Here is the form section for the Status field.
Code:
<td><select class=clsBodyText NAME="status"><% For p = 2 to objRS4.Fields.Count - 1
Response.Write "<option VALUE='" & objRS4.Fields(s) & "' >" & objRS4.Fields(s) & "</option>"
Next%></select></TD></tr><%
objRS4.Close
Set objRS4 = Nothing
%>
The end result is not working. The select statement is populating with the information from the option table and not what is currently in the server table. I'm guessing I need to see first if there is something in the server table, if not use options from the options table. Just not sure how that would look so that it works. I try but not working at all.
Any suggestions/Advice would be greatly appreciated.

Please let me know if more information is needed.
Cheers
 
Old December 18th, 2011, 02:07 AM
Authorized User
 
Join Date: Aug 2011
Posts: 34
Thanks: 1
Thanked 1 Time in 1 Post
Default

So I have been able to populate the form with the existing data and create a drop down for the other options. However, now when I process the update, it does not complete.

Working code for drop down:
Code:
<td>Status:</td>
		<td><select class=clsBodyText NAME="Status"><%
		For s = 2 to objRS4.Fields.Count - 1
		If objRS4.Fields(s) = objRS("status") Then
		Response.Write "<option size=""40"" selected=""selected"" value='"  & objRS4.Fields(s) & "'>" & objRS4.Fields(s) & "</option>" 
		Else
		If objRS4.Fields(s) <> "" Then		
Response.Write "<option VALUE='" & objRS4.Fields(s) & "'>" & objRS4.Fields(s) & "</option>"
End If
End If
Next
Response.Write "</select></TD>"
objRS4.Close
Set ObjRS4 = Nothing
%>
Now my update code from the form:
Code:
 Dim objRS, objConn, objRS2, objConn2    

   Set objConn = Server.CreateObject("ADODB.Connection")
	   objConn.ConnectionString = sConnection
	   objConn.Open
       Set objRS = Server.CreateObject("ADODB.Recordset")
       objRS.Open "Server", objConn, , adLockOptimistic , adCmdTable

  objRS("Status") = Request.Form("Status")
 objRS.Update
       objRS.Close	   
       Set objRS = Nothing	 
      objConn.Close
    Set objConn = Nothing
Thanks for any help,





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to update more than 2 tables walgr2k ASP.NET 2.0 Basics 1 May 19th, 2006 02:01 PM
Need help to update DB2 tables lilychu Classic ASP Databases 0 December 19th, 2003 02:49 PM
fields from tables to update damnnono_86 Access 3 November 5th, 2003 04:07 AM
update tables jjebb Access 7 October 27th, 2003 12:26 PM
Update Multiple Related Tables with 1 Form stephaniejones SQL Server ASP 4 July 13th, 2003 08:52 PM





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