473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

this is driving me batty....

Ok here is a simple page i put together to add entries into a
database....yet its not adding anythign to the database....i cannot see
why not....ideas????
I know i'm a n00b at asp and what i got i kinda pieced together from
another site....but i dont see why this isnt working.

<html>
<Head><Title>Purchasing and Inverntory System</title></head>
<Meta http-equiv="pragma" content="no-cache">
<%

function add1()
dim rsInventory
dim rsSites
dim cmdInventory
dim cmdSites
dim ServerGetDB
dim curItem

Set ServerGetDB = Server.CreateObject("ADODB.Connection")
ServerGetDB.ConnectionString="Provider=Microsoft.J et.OLEDB.4.0;"&"Data
Source=c:\db\purchasing.mdb"
ServerGetDB.open

Set cmdInventory = Server.CreateObject("ADODB.Command")
cmdInventory.CommandText="SELECT * from equip"

Set cmdInventory.ActiveConnection = ServerGetDB
Set rsInventory = cmdInventory.Execute

Set cmdSites = Server.CreateObject("ADODB.Command")
cmdSites.CommandText="SELECT siteName from sites"

Set cmdSites.ActiveConnection = ServerGetDB
Set rsSites = cmdSites.Execute

Response.Write "<form action='add.asp' method='GET' id=formAdd
name=formAdd>"
Response.Write "<table border=1><tr>"
Response.Write "<td>Tag Number:</td><td><input type='text'
name='inv_tag' size='5'></td></tr>"
Response.Write "<tr><td>Equipment Name:</td><td><input type='text'
name='eq_name' size='30'</td></tr>"
Response.Write "<tr><td>Serial Number:</td><td><input type='text'
name='eq_serial_numb' size='30'</td></tr>"
Response.Write "<tr><td>Site:</td><td><select name='site'>"
count=1
do while not rsSites.EOF
Response.Write "<option value='" & trim(rsSites("siteName")) & "'>" &
trim(rsSites("siteName")) & "</option>"
rsSites.movenext
count=count+1
loop
Response.Write "</td></tr>"
Response.Write "<tr><td>Room:</td><td><input type='text' name='eq_room'
size='30'</td></tr>"
Response.Write "<tr><td>Inspection Date:</td><td><input type='text'
name='insp_date' size='10'</td></tr>"
Response.Write "<tr><td>Cetrification Date:</td><td><input type='text'
name='eq_cert_date' size='10'</td></tr>"
Response.Write "<tr><td>Purchase Date:</td><td><input type='text'
name='pur_date' size='10'</td></tr>"
Response.Write "<tr><td>Purchase Price:</td><td><input type='text'
name='pur_price' size='30'</td></tr></table><br><br>"

Response.Write "<input type='submit' name='action' value='Add'>"
Response.write "</form>"

rsSites.close
rsInventory.close
ServerGetDB.close

end function
call main

function AddItem()
dim rsInventory
dim cmdInventory
dim ServerGetDB
dim curItem

Set ServerGetDB = Server.CreateObject("ADODB.Connection")
ServerGetDB.ConnectionString="Provider=Microsoft.J et.OLEDB.4.0;"&"DataSource
= c:\db\purchasing.mdb"
ServerGetDB.open

Set cmdInventory = Server.CreateObject("ADODB.Command")
cmdInventory.CommandText= "SELECT * from equip"

Set cmdInventory.ActiveConnection = ServerGetDB
Set rsInventory = cmdInventory.Execute

Set rsInventory = Server.CreateObject("ADODB.Recordset")
rsInventory.ActiveConnection=ServerGetDB
rsInventory.CursorType=adOpenKeyset
rsInventory.LockType=adLockOptimistic
rsInventory.Source="Select * from equip"
rsInventory.Open

rsInventory.AddNew
rsInventory("insp_date")=request("insp_date")
rsInventory("sites")=request("siteName")
rsInventory("inv_tag")=request("inv_tag")
rsInventory("pur_date")=request("pur_date")
rsInventory("eq_name")=request("eq_name")
rsInventory("eq_serial_numb")=request("eq_serial_n umb")
rsInventory("eq_cert_date")=request("eq_cert_date" )
rsInventory("eq_room")=request("eq_room")
rsInventory("pur_price")=request("pur_price")

Response.Write "Tag # " & Ucase (request("inv_tag")) & " was added."
rsInventory.update
rsInventory.close
ServerGetDB.close
set rsInventory=nothing
set cmdInventory=nothing

setServerGetDB=nothing

end function

sub main()

select case action
case "Add" AddItem()
case "add1" add1()
end select
add1
end sub

%>
</html>

Jan 10 '06 #1
1 1299
Case action ? It looks like this variable is not initialized (could be
Request.form("action") depending on your logic).

You may want also to foce variable declaration by using Option Explicit. It
would have likely catch this one as "action" seems to me also undeclared....
--
Patrice

<mc******@gmail.com> a écrit dans le message de
news:11**********************@g14g2000cwa.googlegr oups.com...
Ok here is a simple page i put together to add entries into a
database....yet its not adding anythign to the database....i cannot see
why not....ideas????
I know i'm a n00b at asp and what i got i kinda pieced together from
another site....but i dont see why this isnt working.

<html>
<Head><Title>Purchasing and Inverntory System</title></head>
<Meta http-equiv="pragma" content="no-cache">
<%

function add1()
dim rsInventory
dim rsSites
dim cmdInventory
dim cmdSites
dim ServerGetDB
dim curItem

Set ServerGetDB = Server.CreateObject("ADODB.Connection")
ServerGetDB.ConnectionString="Provider=Microsoft.J et.OLEDB.4.0;"&"Data
Source=c:\db\purchasing.mdb"
ServerGetDB.open

Set cmdInventory = Server.CreateObject("ADODB.Command")
cmdInventory.CommandText="SELECT * from equip"

Set cmdInventory.ActiveConnection = ServerGetDB
Set rsInventory = cmdInventory.Execute

Set cmdSites = Server.CreateObject("ADODB.Command")
cmdSites.CommandText="SELECT siteName from sites"

Set cmdSites.ActiveConnection = ServerGetDB
Set rsSites = cmdSites.Execute

Response.Write "<form action='add.asp' method='GET' id=formAdd
name=formAdd>"
Response.Write "<table border=1><tr>"
Response.Write "<td>Tag Number:</td><td><input type='text'
name='inv_tag' size='5'></td></tr>"
Response.Write "<tr><td>Equipment Name:</td><td><input type='text'
name='eq_name' size='30'</td></tr>"
Response.Write "<tr><td>Serial Number:</td><td><input type='text'
name='eq_serial_numb' size='30'</td></tr>"
Response.Write "<tr><td>Site:</td><td><select name='site'>"
count=1
do while not rsSites.EOF
Response.Write "<option value='" & trim(rsSites("siteName")) & "'>" &
trim(rsSites("siteName")) & "</option>"
rsSites.movenext
count=count+1
loop
Response.Write "</td></tr>"
Response.Write "<tr><td>Room:</td><td><input type='text' name='eq_room'
size='30'</td></tr>"
Response.Write "<tr><td>Inspection Date:</td><td><input type='text'
name='insp_date' size='10'</td></tr>"
Response.Write "<tr><td>Cetrification Date:</td><td><input type='text'
name='eq_cert_date' size='10'</td></tr>"
Response.Write "<tr><td>Purchase Date:</td><td><input type='text'
name='pur_date' size='10'</td></tr>"
Response.Write "<tr><td>Purchase Price:</td><td><input type='text'
name='pur_price' size='30'</td></tr></table><br><br>"

Response.Write "<input type='submit' name='action' value='Add'>"
Response.write "</form>"

rsSites.close
rsInventory.close
ServerGetDB.close

end function
call main

function AddItem()
dim rsInventory
dim cmdInventory
dim ServerGetDB
dim curItem

Set ServerGetDB = Server.CreateObject("ADODB.Connection")
ServerGetDB.ConnectionString="Provider=Microsoft.J et.OLEDB.4.0;"&"DataSource = c:\db\purchasing.mdb"
ServerGetDB.open

Set cmdInventory = Server.CreateObject("ADODB.Command")
cmdInventory.CommandText= "SELECT * from equip"

Set cmdInventory.ActiveConnection = ServerGetDB
Set rsInventory = cmdInventory.Execute

Set rsInventory = Server.CreateObject("ADODB.Recordset")
rsInventory.ActiveConnection=ServerGetDB
rsInventory.CursorType=adOpenKeyset
rsInventory.LockType=adLockOptimistic
rsInventory.Source="Select * from equip"
rsInventory.Open

rsInventory.AddNew
rsInventory("insp_date")=request("insp_date")
rsInventory("sites")=request("siteName")
rsInventory("inv_tag")=request("inv_tag")
rsInventory("pur_date")=request("pur_date")
rsInventory("eq_name")=request("eq_name")
rsInventory("eq_serial_numb")=request("eq_serial_n umb")
rsInventory("eq_cert_date")=request("eq_cert_date" )
rsInventory("eq_room")=request("eq_room")
rsInventory("pur_price")=request("pur_price")

Response.Write "Tag # " & Ucase (request("inv_tag")) & " was added."
rsInventory.update
rsInventory.close
ServerGetDB.close
set rsInventory=nothing
set cmdInventory=nothing

setServerGetDB=nothing

end function

sub main()

select case action
case "Add" AddItem()
case "add1" add1()
end select
add1
end sub

%>
</html>

Jan 10 '06 #2

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

Similar topics

4
by: pete | last post by:
I found it in the view source of a corporate website. <script Language="Javascript"> <!-- var keyMacro= ]; //--> </script>
2
by: Grey Knight | last post by:
Here's a problem which is driving me slowly insane. Using GCC version 3.3.1 on SuSE 9.0, I keep getting "undefined reference to `function'"-type errors for no apparent reason! It's driving me...
12
by: Marty | last post by:
It seems all of the sudden that user controls that contain images are referencing image sources relative to the document that I drop the control on. This obviously does not work beacuase the...
4
by: robinsand | last post by:
Header File: car.h #if !defined CAR_H #define CAR_H enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize, ctMiniVan, ctSUV }; class Car { public: Car();
0
by: Ronald S. Cook | last post by:
I'm looking for code to calculate the distancde (in miles) between two cities. I'm assuming latitude/longitude would be the inputs (which I'll derive from zip codes being entered by the user). ...
5
by: mark4asp | last post by:
Every time the function below is called I get the alert. So I put a deliberate error in there and I check the value of (reportType=='MANDATE') in Firebug, which is found to be true. But still the...
19
by: bowlderyu | last post by:
Hello, all. If a struct contains a character strings, there are two methods to define the struct, one by character array, another by character pointer. E.g, //Program for struct includeing...
2
amarniit
by: amarniit | last post by:
Consider the following relations concerning a driving school. The primary key of each relation in bold. Student (st_id, class#, th_mark, dr_mark) Student_Driving_Teacher...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.