Add records to a database

S

Stu

I'm using some asp code and a form to add information to a
database. here is the form code:

<FORM METHOD="POST" action="addtrack.asp">
<TABLE BORDER="1" WIDTH="100%">
<TR>
<TD WIDTH="30%">Shipment Tracking Number</TD>
<TD WIDTH="70%"><INPUT TYPE="text" NAME="tracknum"
SIZE="40" TABINDEX="1"></TD>
</TR>
<TR>
<TD WIDTH="30%">Sales Order Number</TD>
<TD WIDTH="70%"><INPUT TYPE="text" NAME="son"
SIZE="40" TABINDEX="2"></TD>
</TR>
<TR>
<TD WIDTH="30%">Company</TD>
<TD WIDTH="70%"><INPUT TYPE="text" NAME="company"
SIZE="20" TABINDEX="3"></TD>
</TR>
<TR>
<TD WIDTH="30%" VALIGN="top">Tracking Info.</TD>
<TD WIDTH="70%" VALIGN="top"><TEXTAREA ROWS="4"
NAME="tinfo" COLS="40" TABINDEX="4"></TEXTAREA></TD>
</TR>
<TR>
<TD WIDTH="30%">Weblink</TD>
<TD WIDTH="70%"><INPUT TYPE="text" NAME="weblink"
SIZE="20" TABINDEX="5"></TD>
</TR>
<TR>
<TD WIDTH="30%"><INPUT TYPE="submit" VALUE="Submit"
NAME="B1" TABINDEX="6"><INPUT TYPE="reset" VALUE="Reset"
NAME="B2" TABINDEX="7"></TD>
<TD WIDTH="70%">&nbsp;</TD>
</TR>
</TABLE>
</FORM>

and here is the asp page that it posts to:

<%
tracknum = Request.QueryString("tracknum")
son = Request.QueryString("son")
company = Request.QueryString("company")
tinfo = Request.QueryString("tinfo")
weblink = Request.QueryString("weblink")

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=C:mypath\mydatabase.mdb"

ADD = "INSERT INTO shipping (tracknum, son, company,
tinfo, weblink) VALUES ('"& tracknum &"','"& son &"','"&
company &"','"& tinfo &"','"& weblink &"')"
Conn.Execute( ADD)

shipping = "SELECT * FROM shipping ORDER BY ID"
Set shipping = Conn.Execute(shipping)



%>
<%
shipping.close

response.redirect("track_entry.htm")
%>

The Problem I'm having, is when I fill in the form and
submit it, it makes a new record in the database, but it
doesnt' add any of the information that i filled out in
the form. Just adds the auto ID number and doesnt' add
the text i typed in. What am I doing wrong?
 
K

Kevin Spencer

You're posting a form, and using Request.QueryString to get the data. Data
from a form is found in the Request.Form collection.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
S

Stu

I tried replacing the Request.QueryString with
Request.Form and I still get the same results, and id
number with no records.
 
T

Thomas A. Rowe

Based on your code sample, you are not passing a ID value.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
K

Kevin Spencer

Hi Stu,

I assume that ID is an autonumber field, which is automatically inserted
when you create a new record? If so, and you have a record with an ID, how
are you viewing the record? Your SELECT query appears just prior to a code
block that redirects to an HTML page. So, are you opening the database to
see the new record? Is the database in the file location specified in your
Connection String? And were there any values in the form fields prior to
inserting the record? If the ID didn't exist in the database prior to
running your script, a record was certainly inserted. If so, the values of
the other fields would have to have been blank.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top