1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Learning ASP, I have a question.

Discussion in 'C#' started by Web Gazelle, Nov 10, 2005.

  1. #1
    I am trying to use an ASP script to change a database yes/no value from no to yes. It is probably simple, but I can't seem to get it to work. Can anyone give me an idea of how to do this? :confused:
     
    Web Gazelle, Nov 10, 2005 IP
  2. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #2
    what type of field is it? what types of database? what query are you using to attempt the update?
     
    iShopHQ, Nov 10, 2005 IP
  3. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #3
    Databse is Access, it is a field in a table in the access database that has a yes/no data type. my query starts like this "update Customers set DeleteCode =..." Customers is the Table and DeleteCode is the table field.
     
    Web Gazelle, Nov 10, 2005 IP
  4. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #4
    Here is my line of code that has a problem.

    What is wrong with it? I keep getting this error.

    Anyone shed some light here?
     
    Web Gazelle, Nov 10, 2005 IP
  5. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    try:

    
    
    var mySQL = "update Customers set DeleteCode = 'True' where Number = '" + Request.Form("Number") + "'"; 
    
    Code (markup):
     
    vectorgraphx, Nov 11, 2005 IP
    Web Gazelle likes this.
  6. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #6
    I will give that a try, thanks.
     
    Web Gazelle, Nov 11, 2005 IP
  7. jpcesar

    jpcesar Peon

    Messages:
    243
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hey are you doing that in VBScript?

    if so then replace the + with &

    var mySQL = "update Customers set DeleteCode = 'Yes' where Number = '" & Request.Form("Number") & "'";

    If Number is integer you don't need the ' ' around request.Form("Number")
     
    jpcesar, Nov 11, 2005 IP
  8. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #8
    Number is an integer but I am using javascript.
     
    Web Gazelle, Nov 11, 2005 IP
  9. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #9
    the yes/no field in access is actually a bit, not the word yes or no.

    in access it is either false (no) or true(yes)

    If Number is an actual data type of NUMBER, not a TEXT or MEMO then you don't need the two sets of quotes. If it isn't, you do.

    to set to yes:
    var mySQL = "update Customers set DeleteCode = TRUE where Number = " & Request.Form("Number")

    to set to no
    var mySQL = "update Customers set DeleteCode = FALSE where Number = " & Request.Form("Number")
     
    iShopHQ, Nov 11, 2005 IP
  10. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #10
    Cool, thanks for the help. The book I am using didn't explain that too well.
     
    Web Gazelle, Nov 14, 2005 IP
  11. iShopHQ

    iShopHQ Peon

    Messages:
    644
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Hope it works...

    If you're anal, like I am, and like everything to balance out, you can still put quotes on the end by putting two next to each other:

    var mySQL = "update Customers set DeleteCode = FALSE where Number = " & Request.Form("Number") &""
     
    iShopHQ, Nov 14, 2005 IP
  12. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #12
    I got it to finally work with this code...

    var mySQL = "update Customers set DeleteCode = TRUE where Number = " + Request.Form("Number")

    Thanks for the help everyone. I guess I need to get a better book. :rolleyes:
     
    Web Gazelle, Nov 15, 2005 IP
  13. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I don't get it at all. What's the point to the last pair of double quotes? You said it had something to do with balance, but it balanced out quite a ways before.

    This may sound like I'm being sarcastic. I'm 100% not. I'm just trying to understand what you're doing.

    Regards,
    James
     
    jimrthy, Dec 8, 2005 IP
  14. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Unless computer books are really cheap wherever you're living, that's probably not the way to go.

    You need to write more code. (So do I, for that matter).

    It sounds to me as though books have taken you about as far as you're going to go. It's time to spread your wings, hop out of the nest, and start doing something with your code.

    That's just my impression, of course. And I'll be the first to admit that I'm most likely wrong.
     
    jimrthy, Dec 8, 2005 IP
  15. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Don't let me answer for ishopHQ, he may mean something different, but what i feel like he means here is basically, while yes, the (& "") is redundant and unnecessary, it is nonetheless logical, i.e. the sql statement starts and ends with quotes, and you escape/reenter your sql statement in pairs. on a simple sql statement like this one it really seems entirely unnecessary, as anyone who works with sql knows you don't need the trailing & "". however, if you have a VERY complex sql statements with lots of nested inner joins, order by clauses, renamed variables, etc... and it's not working right, being sure that all ampersands, apostrophes, #'s, quotes, etc.... are accounted for in pairs can be useful in troubleshooting errors. But you're right, it's not needed at all, especially in something like this - however alot of programmers will go ahead and put it in as a matter of principle.

    too true. I need to write more as well... and i've been writing ASP code every day for over 3 years. Books will only take you so far - real world application and daily usage is the only way to go. TOTAL IMMERSION, BABY! lol :D

    VG
     
    vectorgraphx, Dec 9, 2005 IP
  16. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #16
    I believe in hands-on learning 100%. This was just to get my feet wet. :D
     
    Web Gazelle, Dec 9, 2005 IP
  17. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #17
    wouldn't you be getting your HANDS wet then? hehe

    badum-pum-clash!
     
    vectorgraphx, Dec 9, 2005 IP
  18. jimrthy

    jimrthy Guest

    Messages:
    283
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Ok, that makes sense. Thanks. I haven't seen that technique before.

    Then again, I haven't done much really complex SQL. (The only I've had a job that even got close, we had a DBA to write stored procedures for us. Cake).
     
    jimrthy, Dec 9, 2005 IP
  19. Web Gazelle

    Web Gazelle Well-Known Member

    Messages:
    3,590
    Likes Received:
    259
    Best Answers:
    0
    Trophy Points:
    155
    #19
    I guess I would... Since I like to just dive right in, I would be getting all wet. ;)
     
    Web Gazelle, Dec 12, 2005 IP