SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Problem inupdating database (update occurs but system hangs)

    hello friends

    given below is a code to update a table in a database in a theatre ticket reservaton.

    but this code does not work. it will show loading for long but the database i s updated.

    but theprogress bar shows in progess. whatever after this code does not works.


    code............................................

    fname="../db/ajantha.mdb"
    Set connObj = Server.CreateObject("ADODB.Connection")
    connString="DRIVER={Microsoft Access Driver (*.mdb)};" & "DBQ=" & Server.MapPath(fname)
    connObj.Open connString
    'set rs=Server.CreateObject("ADODB.Recordset")



    i=Request.Form("i") ' i is the no of records passed from previous page.
    j=1
    while j<i ' this loop loops till the no ofrecords is equivalent to the no of records
    select case j
    case 1: ' inserting first rec
    strCommand="update trate set classid="&Request.Form("classid1")&",classname='"&Request.Form("classname1")&"',classrate="&Request.Form("classrate1")&" where classid="&Request.Form("classid1")

    connObj.execute(strCommand)

    case 2: 'inserting2nd record

    strCommand="update trate set classid="&Request.Form("classid2")&",classname='"&Request.Form("classname2")&"',classrate="&Request.Form("classrate2")&" where classid="&Request.Form("classid2")

    connObj.execute(strCommand)
    case 3:
    strCommand="update trate set classid="&Request.Form("classid3")&",classname='"&Request.Form("classname3")&"',classrate="&Request.Form("classrate3")&" where classid="&Request.Form("classid3")
    connObj.execute(strCommand)
    case 4:
    strCommand="update trate set classid="&Request.Form("classid4")&",classname='"&Request.Form("classname4")&"',classrate="&Request.Form("classrate4")&" where classid="&Request.Form("classid4")
    connObj.execute(strCommand)
    end select

    j=j+1
    wend




    please help me from thisproblem


    thank u
    anish

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you doing a multi insert/update?

    Gav

  3. #3
    SitePoint Enthusiast Nawaz Ijaz's Avatar
    Join Date
    Feb 2005
    Location
    Lahore, Pakistan
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you please explain the error message that you get.
    If your program just keep running and nothing returns then most probabbily it is caught in an infinite Loop. Just check it might be possible you forgot to movenext (as i don't know wats you doing after update).

    rs.movenext
    Nawaz Ijaz [Lahore, Pakistan]
    Boy: He is big..i wont like to fight him...
    Achilles: Thatz Y no one wud remember u after thousand years...!!

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2005
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    i am doing a multi insert

    Quote Originally Posted by gRoberts
    Are you doing a multi insert/update?

    Gav

    yes i am doing a multi iinsert.

    after insertion i have to display some message like sucessfully updatedetc..
    but please note that the insertion occurs, but the browser willnot display the sucessfully insert page and it willnot stop navigating(ie the progress bar will be in half way.)

  5. #5
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <%
    
    dim connection
    set connection = server.createObject("adodb.connection")
    connection.open "dsnname"
    
    dim recordset
    set recordset = server.createobject("adodb.recordset")
    recordset.open "SELECT * FROM Table", connection, 2, 2
    
    for i = 1 to 9 
    
    recordset.addnew
    recordset("classid" & i) = request.form("classid" & i)
    recordset("classname" & i) = request.form("classname" & i)
    recordset("classrate" & i) = request.form("classrate" & i)
    recordset.update
    
    next
    
    recordset.close
    connection.close
    
    response.redirect "thankyou.asp"
    %>
    It's not perfect or tested, but should do what you need. Of course if you have a dynamic form situation, then you can send the amount of forms created over to the insert and tell it to go from i = 1 to cint(request.querystring("formlimit"))

    Gav


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •