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 connectionstring for privacy reasons) -
-
<%@ 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>
-
1 1320
If there is no data, but there is a new row, it most likely means that there is no value in the variables you're trying to insert. Set a breakpoint at line 22 and check the value of sSQL.
Apart from that, you still haven't explicitly told your variables of what type they are. You should really do that as it will come back to you to bite you in the butt ;-)
Steven
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steveo |
last post by:
Hi
I have a form containing some text boxes and a button. I'm trying to work
out how to make it so that if certain textboxes contain no data then the
button is not enabled (however still...
|
by: HKM |
last post by:
Hello !
I have extended DataGrid Control as per my requirements. My questions
is how to add this Custom Data Grid to the Form (that I want this
customized grid to appear). Following are the...
|
by: Assimalyst |
last post by:
Hi,
I'm attempting to use a data reader to load data from a single table,
tblCountry, with two columns, countryNo (the Key) and countryName, into
a DropDownList box. Here's the code:
...
|
by: Reny |
last post by:
how do i limit the number of rows in a windows form data grid?
|
by: johnny |
last post by:
hi all,
I wonder if I could do the following task in PHP before searching for
javascript which I prefer not to have in my code:
I have a form to create new tables in a database and, since I...
|
by: Ragbrai |
last post by:
Howdy all,
I have a form for entering data (Form A), on which is a cmd button that opens Form B in acdialog mode to allow me to enter/edit records that are being displayed on Form A.
After...
|
by: asad56 |
last post by:
I am workin with a superstore managment project. I connect Access database with main form . Then it work properly. But now I connect same database with another table or field in another form which is...
|
by: =?Utf-8?B?V2FsaWQ=?= |
last post by:
Hello:
I have migrated a site from IIS5 to IIS6. The site is configured and the we
app is installed on the new IIS site. I can get to the web page but when I
try to login, this is what I get...
|
by: Paddy |
last post by:
The problem I am facing is as follows:
I am populating an HTML table on my webpage with rows of data from a
database. The rows may be sometimes 10 and sometimes say,3. I have two
buttons on that...
|
by: mariaz |
last post by:
Hello, I am creating a project where I parse an xml page (feed from a website) in a javabean file and I insert the parsed data in a mysql database. I want this data that gets inserted into the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |