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) -
-
<%@ 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 1334
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 visible).
Firstly I can't work out how to make a button un-enabled (is this a word? i
hope you know what i mean!) and secondly I'm not sure how to make...
|
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 blocks of code.
public class CustomDataGrid : DataGrid
{
public CustomDataGrid()
|
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:
protected System.Data.SqlClient.SqlConnection conn;
protected System.Data.SqlClient.SqlDataReader drCountry;
|
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 can't
know how many columns needs each table, I want to load the page with a
single text field in the form and then with a button adding more...
| |
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 adding/editing a record on Form B (opened in acDialog mode), I want a cmd button on Form B to close Form B and then have Form A automatically take me to...
|
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 child of main form not working.
Main form stil working but when try to open child a message show as
Please select a valid...
|
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 the following error below. I would
appreciate any insight, direction or help regarding this.
Thank-you!!
Walid
|
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 page "Next" and "Previous" which I want displayed just
a couple of lines below the table dynamically. Thus the positions of
these buttons would vary...
|
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 database to be shown in my project when it deploys (the project is jsf and I am using NetBeans). What I want to ask is how can I update the data of the...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |