Double Quotes in a SQL Query.. RRS feed

  • Question


    Hi All - i will try and keep this simple - i need to do a find and replace from a string.

    basically i want to find a (') and replace it with double Quotes (")

    i thought the following would work - but nope!

    sql.replace(" ' ", " " ")   <-- ignore the spaces, just so you can see what i mean...

    Reason for the replace: i want to use a double quote in an sql query - but cannot type it in, so i figured a replace should sort out the problem.

    this is what iam using:


    date = textbox1.text

    sql = "select * from Table where duedate>datevalue(" & date & ")


    this is what i get at run time.

    sql = "select * from Table where duedate>datevalue(01/01/2007)


    hence i thought i could use:

    sql = "select * from Table where duedate>datevalue('" & date & "')

    sql.replace(" ' ", " " ")  


    did i confuse anyone! - i have google and searched - but cannot find an answer!

    this is the last thing i need before i can distribute my project - its killing me!

    Thanks Poy

    New To Vb.net - so a little Naive!

    Saturday, October 20, 2007 12:17 PM


  • Hi Poy,


    You've posted this in the wrong place. Hopefully someone will move it. On occasion people get grumpy, and they are entitled to, when someone else answers posts placed in the wrong place. I understand why posted here.


    It shouldn't matter if you use single or double quotes, the two are interchangeable, you just can't mix them.


    'this is fine'

    "this is fine"

    'this isn't fine"


    Saturday, October 20, 2007 1:10 PM