neillovell
Programmer
I've grabbed this code from
But I'm having trouble with the second file. It will not write to my database. The first and second (create form and submit, and display data in table) files are fine, but it's this second...
My database (.mdb) is called TempASPLink and the table fields are firstname and lastname
<HTML>
<HEAD>
<TITLE>Text to Database</TITLE>
</HEAD>
<BODY>
<%
firstname=request.form("firstname"
lastname=request.form("lastname"
%>
<%
accessdb="TempASPLink"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
set rs = Server.CreateObject("ADODB.Recordset"
sql = "insert into testtable (lastname, firstname) "
sql = sql & "values ('" & firstname
sql = sql & "','" & lastname & "')"
rs.Open sql, cn
%>
<font face = "arial" size="1">
First Name <%= firstname %>
<br>
Last Name <%= lastname %>
<br>
has been added to the db <br>
<a href = "input_text_db_view.asp">View the Table</a>
</font>
</BODY>
</HTML>
But I'm having trouble with the second file. It will not write to my database. The first and second (create form and submit, and display data in table) files are fine, but it's this second...
My database (.mdb) is called TempASPLink and the table fields are firstname and lastname
<HTML>
<HEAD>
<TITLE>Text to Database</TITLE>
</HEAD>
<BODY>
<%
firstname=request.form("firstname"
lastname=request.form("lastname"
%>
<%
accessdb="TempASPLink"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
set rs = Server.CreateObject("ADODB.Recordset"
sql = "insert into testtable (lastname, firstname) "
sql = sql & "values ('" & firstname
sql = sql & "','" & lastname & "')"
rs.Open sql, cn
%>
<font face = "arial" size="1">
First Name <%= firstname %>
<br>
Last Name <%= lastname %>
<br>
has been added to the db <br>
<a href = "input_text_db_view.asp">View the Table</a>
</font>
</BODY>
</HTML>