473,473 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inserting data into a table

I am quite new to all this but am trying to create a database driven site. I
have been able to use information from my sample database but I now want to
be able to insert data into it. At present I put the data into my local copy
of the access database and then upload it again to my server - not an ideal
solution!

I have tried using the INSERT command and it works fine if I enter the data
into the statement. What I really want to do is collect the data from a form
and then insert this into the database. My code is as follows:

Page for collecting the data:

<form name="useradd" method="post" action="testadd.asp">
<p>Username:
<input type="text" name="username">
</p>
<p>Password:
<input type="text" name="password">
</p>
<p> Category:
<select name="select">
<option>member</option>
<option>committee</option>
<option>admin</option>
<option>guest</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
I then have the following code on the page (testadd.asp) to add this
information to my database.

<%
u = Request.Form("username")
p = Request.Form("password")
c = Request.Form("category")

Set Catalog=Server.CreateObject("ADODB.Recordset")
Catalog.open "INSERT INTO tbltest (username, password, category) VALUES (u ,
p, c)", "DSN=members"
%>

The thing which goes wrong is the VALUES part of the statement. It seems to
want 'u' etc but then puts in this text rather than the contents of my
variable.

Any help most welcome.

Geoff Wickens
Jul 19 '05 #1
1 3658
You forgot to reference the actual data itself

INSERT INTO tbltest (username, password, category)
VALUES (' " & u & " ',' " & p & " ',' " & c & " ')

note use of single quotes to delimit the text fields - I have put extra
space between single and double quote to be clear - you should remove other
wise your stored data will have leading and trailing space
"Geoff Wickens" <gw******@hotmail.com> wrote in message
news:NS**************@newsfep1-gui.server.ntli.net...
I am quite new to all this but am trying to create a database driven site. I have been able to use information from my sample database but I now want to be able to insert data into it. At present I put the data into my local copy of the access database and then upload it again to my server - not an ideal solution!

I have tried using the INSERT command and it works fine if I enter the data into the statement. What I really want to do is collect the data from a form and then insert this into the database. My code is as follows:

Page for collecting the data:

<form name="useradd" method="post" action="testadd.asp">
<p>Username:
<input type="text" name="username">
</p>
<p>Password:
<input type="text" name="password">
</p>
<p> Category:
<select name="select">
<option>member</option>
<option>committee</option>
<option>admin</option>
<option>guest</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
I then have the following code on the page (testadd.asp) to add this
information to my database.

<%
u = Request.Form("username")
p = Request.Form("password")
c = Request.Form("category")

Set Catalog=Server.CreateObject("ADODB.Recordset")
Catalog.open "INSERT INTO tbltest (username, password, category) VALUES (u , p, c)", "DSN=members"
%>

The thing which goes wrong is the VALUES part of the statement. It seems to want 'u' etc but then puts in this text rather than the contents of my
variable.

Any help most welcome.

Geoff Wickens

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Joachim Klassen | last post by:
Hi all, first apologies if this question looks the same as another one I recently posted - its a different thing but for the same szenario:-). We are having performance problems when...
2
by: a | last post by:
NEW Post Here's my best guess at how to insert this dataset.... the code runs, but no new records are added to the sql table. I've read and split a delimited text file into a dataset. It...
3
by: rcoco | last post by:
Hi, I want to share this problem. I have a datagrid that will help me Insert data into sql database. So I made a button On my form so that when I press the button a new row on datagrid should be...
2
by: Etayki | last post by:
Hi! I am trying to insert data into a MS SQL Database from a Console Application written in VB.net I have already created the table in the database and I am able to read values. When I insert a...
1
by: madhuxml82 | last post by:
Dear Forum Members, I have generated an XML Schema and a Table of XMLType referencing the XML Schema. Now When I am Inserting the Data into the Table. I am getting the Error 0RA-30937: Error is...
5
by: dos360 | last post by:
Hello, I have two tables, one is a list of activities, the other a list of participants. I want to insert one record in the activities table and then using its identity column as foreign key, I...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
2
by: cluce | last post by:
I am trying to read a csv file with user info (username, password, email, address, city, zip, state, etc.) I am inserting the username, password, email into the aspnet_memberhsip table using the...
5
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
5
by: billelev | last post by:
I have a large array of data (1000 x 40 x 3) that I am inserting into a database table. It is incredibly slow, and so I was wondering if there is a quicker way of inserting array data into a table....
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.