this is driving me batty....

Discussion in 'ASP General' started by mcgavock@gmail.com, Jan 10, 2006.

  1. Guest

    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>
     
    , Jan 10, 2006
    #1
    1. Advertising

  2. Patrice Guest

    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

    <> a écrit dans le message de
    news:...
    > 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>
    >
     
    Patrice, Jan 10, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Nicklas

    Driving INOUT ports

    Mike Nicklas, Feb 23, 2004, in forum: VHDL
    Replies:
    0
    Views:
    587
    Mike Nicklas
    Feb 23, 2004
  2. Henk De Denktenk
    Replies:
    6
    Views:
    681
  3. Andy Peters

    Driving signals from a procedure

    Andy Peters, May 19, 2005, in forum: VHDL
    Replies:
    4
    Views:
    922
    Jonathan Bromley
    May 20, 2005
  4. Alex
    Replies:
    3
    Views:
    508
  5. Paul Watt

    ok,this css is driving me batty

    Paul Watt, Apr 4, 2006, in forum: HTML
    Replies:
    3
    Views:
    356
    dorayme
    Apr 5, 2006
Loading...

Share This Page