SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 45 of 45
  1. #26
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey r937


    I have tried that way too. If I enter details in the field it sholud update in the database too. But it is showing only on the form.. not adding to database..


    SQL = "UPDATE itemsSET Item='"&item&"', company= '"&company&"' WHERE Itemid = " & itemid
    Set RS=Conn.Execute(SQL)
    Conn.Close
    Response.Redirect("main.asp")

    But no luck.

  2. #27
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no luck webber..
    None of them are working..

  3. #28
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Off Topic:

    disappointed cat is... disappointed
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #29
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lucky20 View Post
    no luck webber..
    None of them are working..
    so much of what you post back here in code is full of new errors it's impossible to know what you mean when you say the code is not working

    folks can't assist with fragmented information.

    your most recent post has yet another error and is not what I gave you.

    Code ASP:
    SQL = "UPDATE itemsSET Item='"&item&"', company= '"&company&"' WHERE Itemid = " & itemid

    you have "itemsSET " as one word ....

  5. #30
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey i am copying code from asp page to this website.

    In the mean time i have did mistakes.

    There is a gap between table name and set.
    SQL = "UPDATE items SET Item='"&item&"', company= '"&company&"' WHERE Itemid = " & itemid
    Set RS=Conn.Execute(SQL)
    Conn.Close
    Response.Redirect("main.asp")

    I could n't figure out the error.
    Why it is not updating the data in sql table..

  6. #31
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's a nightmare for me.. I couldn't get the proper result what i expected..

    It's my bad.

  7. #32
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the code i gave you does work - I tested it

    Since you are updating the database - nothing will change unless the database has an existing record with the itemid entered in the form. if the submitted itemid doesn't exist nothing is found and nothing is updated.

    Update does not mean add new record, it means change an existing record.

    make sure the database has a record with the itemid in use - otherwise you will need to write code to output a response when the matching itemid is not found.

  8. #33
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @webber
    I have used existing records only.. but still no use..

  9. #34
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then you will need to hire someone to go in and fix it for you.

  10. #35
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hahaa..

    If i have that much money i should do that in future...

    At present I need to fix this to get that kind of life...

    why don't you give a try..

  11. #36
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    YOU'RE NOT USING THE SQL CODE THAT WEBBER GAVE YOU!

    Sheesh!
    Ian Anderson
    www.siteguru.co.uk

  12. #37
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @ site guru
    I have used what webber mentioned there and same to r937.

    But i didn't post it here.. that 's it.

    But no luck..no record is updating..but taking values from form.

    I am considering everyones opinion..I don't know which one is correct.. So i am trying all the ways to get the result.

    don't think like that..

  13. #38
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by lucky20 View Post
    @ site guru
    I have used what webber mentioned there and same to r937.

    But i didn't post it here.. that 's it.

    But no luck..no record is updating..but taking values from form.

    I am considering everyones opinion..I don't know which one is correct.. So i am trying all the ways to get the result.

    don't think like that..
    I gave you a complete tested working solution.

    If you are mixing it with other code then it definitely is going to fail. You can't just mix and match and hope it works.

  14. #39
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The simple solution for us to help you is this - post ALL the code you are using. The WHOLE PAGE. And post them using at least [ code][/code] tags (better still using the ASP highlight tags [ HIGHLIGHT="ASP"][/HIGHLIGHT]) so that the code is properly formatted. (Remove the space between [ & code] or [ & HIGHLIGHT] for them to work - I just put them there so you could see the format). NOT using such tags makes it hard to read your code.

    Code:
    str = "Code using CODE tags"
    Code ASP:
    str = "Code using HIGHLIGHT tags"
    Ian Anderson
    www.siteguru.co.uk

  15. #40
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Hooray.. My code is executing successfully..

    Plz check the code


    Thanks siteguru& webber..

    previously i did mistake at If condition.. Now I corrected it..


    Asp Code:
    <%
    Dim SQL

    OpenSQLConn
    If Request("Update") <> " " Then

    itemid = Request.Form("itemid")
    item=Replace(Request("item"),"'","''")
    company=Replace(Request("company"),"'","''")
    SQL = "UPDATE items SET Item= '"&item&"', Company= '"&company&"' WHERE Itemid = " & itemid

    Set RS=Conn.Execute(SQL)

    Conn.Close
    Response.Redirect("main.asp")


    End If
    %>


    Html Code
    <html>
    <body>
    <form method="post" action="eitem.asp">
    <table>
    <tr>
    <td>Item Id</td>
    <td><input type="text" name="itemid"></td> </tr>
    <tr>
    <td>Item </td>
    <td><input type="text" name="item"></td></tr>
    <tr>
    <td>Company</td>
    <td><input type="text" name="company"></td></tr>
    </table>
    <input type="submit" value="Update" name="Update">
    <input type="submit" value="Back" Name="back">

    </form>
    </body>
    </html>

  16. #41
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    <snip>
    More fulsome post below.
    Last edited by siteguru; Nov 4, 2010 at 08:01. Reason: Forum error when creating post
    Ian Anderson
    www.siteguru.co.uk

  17. #42
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I would replace Request with Request.Form for ALL of your values/checks.

    I would also validate that each value contains valid data, and of the correct type, BEFORE doing any SQL commands. (Your code as it stands is wide open to SQL injection attackes).

    PS - which part of "Post your code using CODE or HIGHLIGHT tags" did you not understand?
    Code ASP:
    <%
    Dim SQL,itemid,item,company,RS
     
    If Request.Form("Update") = "Update" Then 
      itemid = Request.Form("itemid")
      item=Replace(Request.Form("item"),"'","''")
      company=Replace(Request.Form("company"),"'","''")
      If IsNumeric(itemid) AND Len(item) > 0 AND Len(company) > 0 Then
        OpenSQLConn
        SQL = "UPDATE items SET Item='"&item&"', Company='"&company&"' WHERE Itemid=" & itemid 
        Set RS=Conn.Execute(SQL)
        Conn.Close
        Response.Redirect("main.asp")
      Else
        Response.Write "<p>You haven't completed the form correctly</p>"
      End if
    End If
    %>
    Code HTML4Strict:
    <html>
    <body>
    <form method="post" action="eitem.asp">
    <table>
      <tr>
        <td>Item Id</td>
        <td><input type="text" name="itemid"></td> </tr>
      <tr>
        <td>Item </td> 
        <td><input type="text" name="item"></td></tr>
      <tr>
        <td>Company</td>
        <td><input type="text" name="company"></td>
      </tr>
    </table>
    <input type="submit" value="Update" name="Update">
    <input type="submit" value="Back" Name="back">
    </form>
    </body>
    </html>
    Ian Anderson
    www.siteguru.co.uk

  18. #43
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No need to check your code - I gave you clean working code yesterday and you still refuse to use it. The code I provided fixed the if statement and it also fixed the Request.Form deficiencies you still continue to carry along in your poorly written code.

    Now Siteguru has written you another block of working code, and I'll bet you won't use it either.

  19. #44
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @ webber..
    I used siteguru code..
    Now i understand ,what's wrong in my code..

    Thanks Siteguru..I executed it successfully..
    I got the result what i expected..

    Thanks for your help..

  20. #45
    SitePoint Enthusiast lucky20's Avatar
    Join Date
    Oct 2010
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @ webber..
    I didn't refuse it..
    I don't have much knowledge about this asp..

    So I don't know how to use it..

    I think you can understand what my knowledge level on ASP..

    thanks Webber..


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
  •