Results 1 to 8 of 8

Thread: Help please.........

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37

    Help please.........

    Hi, I just ran into a serious problem ( well for me it is ).
    I'm developing a website, which allows the user to send each other messages in the form of mail. I store the message into my database and display it when needed.

    Well the problem is this:

    "INSERT INTO tblSomething( fldMessage ) VALUES( '" & strMessage & "' )"

    The database will complain about this statement because strMessage may have ('), which well delimate the string value.

    Is there an easier way to handle this situation rather than going through each character in strMessage and changing the (') to its code???

    That could be devistating to the speed.

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Try:
    VB Code:
    1. "INSERT INTO tblSomething( fldMessage ) VALUES(" & """" & strMessage & """" & " )"

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37

    I just thought of something

    If I convert the string into bytes, then maybe that'll solve the problem. Any suggestions???

    Anybody know the convertion function? ( in ASP )

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37

    Thanks Beacon but it didn't work.

    --

  5. #5
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Any errors???

    Perhaps i had too many quotes
    VB Code:
    1. "INSERT INTO tblSomething( fldMessage ) VALUES(" & """" & strMessage & """" & " )

    Not in ASP but this is how i got around using the ' with sql. It happens coz it's a special character!

    VB Code:
    1. rs1.Open "Select * FROM tbl_clientcd Where tbl_clientcd.[ClientCode] =""" & strcode & """;", cn1, adOpenKeyset, adLockPessimistic, adCmdText
    Perhaps have a look at that!

    good luck
    b

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2001
    Posts
    37

    Didn't work

    First - I think it's complaining because their " in the message also
    Seoncd - When I removed all the " I got this error message:
    '' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long

    So I'm not really sure what to do now.........

    What do you think about converting into bytes, is it even feasable?

    (Don't mind the typos)

  7. #7
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Hmm weird i dont know asp that well but try PMing these 2 guys ask them to have a look at it:

    Sail3005
    JoshT

    They know thier asp stuff well. But usually that works with SQL!

  8. #8
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Perphaps u can try this two things:

    Just before the insert

    1)strMessage = replace(strMessage ,"'","''")

    2)strMessage = server.htmlencode(strMessage )

    Hope one of this helps u.

Posting Permissions

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



Click Here to Expand Forum to Full Width