I have a form that i want to be saved to my database. The form is adding a new record to my sql server 2005 database but it is not bringing the text over with it. The new record in my db is just an empty row. Here is my code.
Add to database section ( i have removed the connectionstrin g for privacy reasons)
Add to database section ( i have removed the connectionstrin g for privacy reasons)
Code:
<%@ Page aspcompat="true" Debug="true" %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'declare your variables
Dim FirstName, LastName, Comments, MRN, Age, CathDate
Dim sConnString, connection, sSQL
'Receiving values from Form, assign the values entered to variables
FirstName = Request.Form("FirstName")
LastName = Request.Form("LastName")
Comments = Request.Form("Comments")
MRN = Request.Form("MRN")
Age = Request.Form("Age")
CathDate = Request.Form("CathDate")
'declare SQL statement that will query the database
sSQL = "INSERT into tblPatientInfoTest (FirstName, LastName, Comments, MRN, Age, CathDate) values ('" & _
FirstName & "', '" & LastName & "', '" & Comments & "', '" & MRN & "', '" & Age & "', '" & CathDate & "')"
'define the connection string, specify database
'driver and the location of database
'create an ADO connection object
connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)
'execute the SQL
connection.execute(sSQL)
Response.Write("The form information was inserted successfully.")
'Done. Close the connection object
connection.Close
connection = Nothing
%>
</body>
</html>
Comment