Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    Unanswered: Update query help

    hi all, i've search my problem in some forum and try googling it but i can't find the right keyword. I hope you can help me.

    I'm using sql server 2005 and combined with asp classic (vb).

    I have a table with 3 column , the table itself is about airport tax. 3 column there : City, Airport, and Tax. What i want to do is sql update tax value column whenever admin press save button. sounds easy for me at first. Displaying every row in sql server smoothly and i think, the same goes for saving tax value.

    so the query for update maybe like this it's in loop statement while rsTarif not eof:
    Code:
    set rsTarif=Server.CreateObject("ADODB.Recordset")
    strTarif="select * from airport_tax"
    set rsTarif = objConn.execute(strTarif)
    
    strUpdate="UPDATE airport_tax SET Tax="& request("txt|"& rsTarif("Tax")) &" WHERE City='"& rsTarif("City") &"' AND Airport='"& rsTarif("City") &"'"
    query sounds good, since i have fulfill update (table_name) set value=(value filled in html form) where city= X and airport= Y (just to make sure to update every row).

    i give some sql data for example

    City Airport Tax
    X Y 1000
    A B 1500
    C D 2000
    E F 1000

    when update query executed, i show the result to web page and the result is

    update airport_tax set Tax=1000,1000 where city=X and airport=Y
    update airport_tax set Tax=1500 where city=A and airport=B
    update airport_tax set Tax=2000 where city=C and airport=D
    update airport_tax set Tax=1000,1000 where city=E and airport=F

    why the same value of tax get into the set Tax while the different one just fine?incorrect update syntax or incorrect loop?

    i'm stuck at this, i can't debug since i don't know the problem. Thanks for all your help

  2. #2
    Join Date
    Mar 2009
    Posts
    349
    I suspect it has to do with what is in red.

    strUpdate="UPDATE airport_tax SET Tax="& request("txt|"& rsTarif("Tax")) &" WHERE City='"& rsTarif("City") &"' AND Airport='"& rsTarif("City") &"'"

  3. #3
    Join Date
    Apr 2008
    Location
    Along the shores of Lake Michigan
    Posts
    242
    Quote Originally Posted by tyo07
    i can't debug since i don't know the problem
    Isn't that what debugging is meant to do, to "find" and "correct" the problem??

  4. #4
    Join Date
    Jun 2009
    Posts
    2
    delete one from where clause doesn't make change. still confuse. never get this error before. anyway thanks for your effort to help.

Posting Permissions

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