this is driving me batty....

M

mcgavock

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.Jet.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.Jet.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_numb")
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>
 
P

Patrice

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....
 

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

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top