I am a newbie with ASP/VBScript and am trying to create a test page that will add a record to a table. I plan on using these concept for something real later and can't figure out whats wrong with my code. My intent is to use ADO (also new to me). I've created a System DSN called "TestAdd", my MS Access database is called "NameColor.mdb" and the table name is ""tblsqladd". There are four fields in the table 1=id 2=FirstName 3=lastName and 4=FavoriteColor. Could someone please help me figure out what I've done wrong!
The code for my input form page (called default.asp) is this:
<html>
<head><title>Test Adding a Record to Table</title></head>
<body>
<h3 align="center">SQL Add example</h3>
<td width="424"><form method="post" name="form1" action="addrecord.asp">
<p><strong>First Name</strong><br>
<input type="text" size="40" name="txtFirst"><br>
<strong>Last Name</strong><br>
<input type="text" size="40" name="txtLast"><br>
<strong>FavoriteColor</strong><br>
<input type="text" size="40" name="txtColor"><br>
<p><input type="Submit" value="Submit New Example" name"b1"> </font></p>
</form>
</td>
</tr>
</table>
</center></div>
</body>
</html>
My code for addrecord.asp is this:
<%
Option Explicit
'Declare variables
Dim strFName
Dim strLName
Dim strColor
Dim SQLINSERT
Dim connupdate
'Grab variables from the querystring.
strFName=Request.Querystring("txtFirst"
strLName=Request.Querystring("txtLast"
strColor=Request.Querystring("txtColor"
'Create the INSERT statement for a brand new client.
SQLINSERT="INSERT INTO tblSqlAdd (txtFirst, txtLast, txtColor) "
set connupdate = server.createobject("ADODB.Connection"
connupdate.open "TestAdd"
connupdate.execute(SQLINSERT)
connupdate.close
set connupdate = nothing
%>
<html><head>
<title>SQL Add record example</title>
</head>
<body>
<% Response.Write "Your record has been added" %>
</body>
</html>
Any ideas as to what I'm doing wrong??? Thanks!!!
The code for my input form page (called default.asp) is this:
<html>
<head><title>Test Adding a Record to Table</title></head>
<body>
<h3 align="center">SQL Add example</h3>
<td width="424"><form method="post" name="form1" action="addrecord.asp">
<p><strong>First Name</strong><br>
<input type="text" size="40" name="txtFirst"><br>
<strong>Last Name</strong><br>
<input type="text" size="40" name="txtLast"><br>
<strong>FavoriteColor</strong><br>
<input type="text" size="40" name="txtColor"><br>
<p><input type="Submit" value="Submit New Example" name"b1"> </font></p>
</form>
</td>
</tr>
</table>
</center></div>
</body>
</html>
My code for addrecord.asp is this:
<%
Option Explicit
'Declare variables
Dim strFName
Dim strLName
Dim strColor
Dim SQLINSERT
Dim connupdate
'Grab variables from the querystring.
strFName=Request.Querystring("txtFirst"
strLName=Request.Querystring("txtLast"
strColor=Request.Querystring("txtColor"
'Create the INSERT statement for a brand new client.
SQLINSERT="INSERT INTO tblSqlAdd (txtFirst, txtLast, txtColor) "
set connupdate = server.createobject("ADODB.Connection"
connupdate.open "TestAdd"
connupdate.execute(SQLINSERT)
connupdate.close
set connupdate = nothing
%>
<html><head>
<title>SQL Add record example</title>
</head>
<body>
<% Response.Write "Your record has been added" %>
</body>
</html>
Any ideas as to what I'm doing wrong??? Thanks!!!