Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send ASP Form fields to Access Database

Status
Not open for further replies.

SHAWTY721

Programmer
Aug 16, 2007
116
0
0
US
Hi I have a html form that I am calling an asp form from and I can't get the fields into the database. I'm not sure if I'm missing part of the needed code.

Code:
<% @ Language="VBScript"%>
<%

' Declaring variables
Dim PlayerName, BDate, Grade, Address, City, Zip, Email, School, District, HPhone, CPhone, Email2, Con, Data_Source, SQL_Insert
Dim rs
Dim strconn
Dim strlD

' A Function to check if some field entered by user is empty
Function ChkString(string)
	If string = "" Then string = " "
	ChkString = Replace(string, "'", "''")
End Function

'Sets up the connection to the database(The entire line 9 must be on one line)
set strconn=server.createobject("adodb.connection")
strConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Registration.mdb")

'Create an ADO recordset object
set rs = server.createobject("adodb.recordset")

'Initialise the strID variable with an SQL statement to query the database
strID = "SELECT RegistrationInfo.Bdate, RegistrationInfo.Grade, RegistrationInfo.Name, RegistrationInfo.Address, RegistrationInfo.City, RegistrationInfo.Zip, RegistrationInfo.Email, RegistrationInfo.School, RegistrationInfo.District, RegistrationInfo.Home, RegistrationInfo.Cell, RegistrationInfo.Email2;"

'Set the cursor type we are using so we can navigate through the recordset
rs.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rs.lockType = 3		

'Open the recordset with the SQL query (the 2,2 deals with writing and locking the table)
rs.Open strID, strconn, 2,2

'Adds new data from the Form to the Table
rs.addnew

rs("bdate") = request("Bdate")
rs("grade") = request("Grade")
rs("playername") = request("PlayerName")
rs("address") = request("Address")
rs("city") = request("City")
rs("zip") = request("ZipCode")
rs("email") = request("Email")
rs("school") = request("School")
rs("district") = request("District")
rs("hphone") = request("HPhone")
rs("cphone") = request("CPhone")
rs("email2") = request("Email2")

'Updates the Table and Moves to end of record
rs.update	

rs.movelast
'Closes all the connections to the Database

set rs = nothing	
set conn = nothing
%>


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Tryout Submission</title>

</head>

<body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFF00">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td align="right" width="57%" bgcolor="#000000">
                <p align="center">
                        <b> <font face="verdana, Arial, Helvetica" size="4" color="#FFFFFF">Welcome
                        To The Official Web Site Of<br clear="all">
                        &nbsp;The Ohio Hardwood Heat<br clear="all">
                        Girls' AAU Basketball An Ohio AAU Member</font></b></p>
				</td>
				<td align="right" width="43%" bgcolor="#000000">
                <p align="center"><img border="0" src="images/hhlogo_small.png" width="285" height="132" align="right">                </p></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" height="35">
			<tr>
				<td width="100%" align="right" bgcolor="#FE5E01" height="35">
				<img src="images/top_con_01.gif" width="100%" height="28">
                </td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" background="images/top_02_bg.gif">
			<tr>
				<td><img src="images/top_02_bg.gif" width="6" height="15"></td>
			</tr>
		</table>
		</td>
	</tr>



	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
			  <td>
				
			  </td>
							</tr>
							<tr>
							  <td>
							  </td>
							</tr>
		  </table>
						<br>
	  </td>
  </tr>
</table>
				</td>
<td valign="top">
                        <p align="center"><font face="verdana, Arial, Helvetica" size="5">
                        <p align="center">Thank you for submitting your tryout registration.</p>
                        <p align="center"> Your registration has been successfully submitted.</p>
                        <p align="center">Your registration was received at 
                          <!-- #BeginDate format:fcAm1a -->Wednesday, January 21, 2009 10:57 PM<!-- #EndDate -->
                        </p>
                        <p align="center">&nbsp;</p>
						<p align="center">center>Please click <a href="/mainpage.html">here</a> to return to the home page
                        </font>
                        <blockquote>
                          <p align="center"><font face="verdana, Arial, Helvetica" size="5">We look forward to seeing you at tryouts!
                          </font></p>
                        </blockquote>
                        <font face="verdana, Arial, Helvetica" size="5">
                        <p align="center">&nbsp;</p>
                        </font></td>
</tr>
					<tr>
						<td background="images/banner_bg.gif" width="576" valign="top" height="25">
                        <b>&nbsp;&nbsp; <font face="verdana, Arial, Helvetica" size="4">&nbsp;</font></b></td>
					</tr>
				</table>
				<table width="100%" border="0" cellspacing="10" cellpadding="0">
					<tr>
						<td>                                         
                        <p align="center"><b><font size="4" color="#000000"><br>
                          </font></b>
                          <br>                        
                        <table border="0" width="100%">
                          <tr>
                            <td width="100%"><!--<p>&nbsp;<b>Tryout dates and times will be posted by January 1<sup>st</sup></b></td> -->                                                  </tr>
                        </table>
                        <p align="center">&nbsp;</p>
                        <p align="center"><b><font size ="4" face="Verdana, Arial, Helvetica"></font></b></p>
                        <p align="center"><b><font size="4" face="Verdana, Arial, Helvetica"></font></b></p>
                        <p align="center">
                        <br>
                        <p align="center">&nbsp;</p>
                        <hr width="60%" color="#FE5E01">
                        <div align="center">
                          <center>
                          <table border="0" cellpadding="0" cellspacing="0" width="99%">
                            <tr>
                              <td width="15%">                              </td>
                              <td width="85%">
                              <p align="center">                              </td>
                            </tr>
                          </table>
                          </center>
                        </div>
                        <p>&nbsp;</p>
                        
                        <table border="0" style="border-collapse: collapse" width="100%" cellpadding="0">
							<tr>
								<td>
                            
                                <p>                                </p>                                </td>
							</tr>    
					  <tr>
				  <td bgcolor="#FE5E01">
                                <p align="center"><font color="#FFFF00" size="2"><b>If
                                you'd like to advertise on this Heat Web Page -

                                Contact <a href="mailto:billkroth@aol.com">Bill
                        Kroth</a></b></font>                        </td>
						  </tr>
						</table>					  </td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#900000">
			<tr>
				<td width="752">&nbsp;</td>
			</tr>
		</table>
		</td>
	</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="images/last_bg.gif">

	<tr align="center">
		<td><img src="images/last_bg.gif" width="10" height="54"></td>
	</tr>
</table>

</body>

</html>
 
The code is looking for values sent from the form. That is what the

rs("grade") = request("Grade")
rs("playername") = request("PlayerName")
etc

part is - the request comes from the html form.

Can you post the form code so we can verify that your form is sending a grade and a playername etc (ie has the correct elements correctly named)?
 
Assuming you have the correct form control names, wouldn't the code be
Code:
rs("bdate") = request[b][red].form[/red][/b]("Bdate")
rs("grade") = request[b][red].form[/red][/b]("Grade")
rs("playername") = request[b][red].form[/red][/b]("PlayerName")

Duane
Hook'D on Access
MS Access MVP
 
Well, actually, both request("Grade") and request.form("Grade")will work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top