My apologies!!! Too busy watching TV, I didn't realise I was in the VB
group, not the .NET one I'm usually in!!
Here's a "translation".. .
Public Function MakeSQLString(p StringToBeSQLd As String) As String
' Define apostrophe from good ol' ASCII number
Dim vApostrophe As String = Chr(39)
' Double up any apostrophes
Dim vOutput As String = Replace(pString ToBeSQLd, vApostrophe, vApostrophe
& vApostrophe)
' Add apostrophes to each end of the string
MakeSQLString = vApostrophe & vOutput & vApostrophe
End Function
Usage;
Dim vName As String
Dim vSQL As String
vName = "Grim"
vSQL = "SELECT * FROM myTable WHERE myWhereClause=" & MakeSQLString(v Name) &
";"
..... <query DB>
_______________ _______________ ___
The Grim Reaper
"The Grim Reaper" <gr*********@bt openworld.com> wrote in message
news:ca******** **@titan.btinte rnet.com...
My standard "MakeSQLStr ing" function has been the same for many years...
(although recently upgraded to .NET and can probably be improved on...
lol)
Public Function MakeSQLString(p StringToBeSQLd As String) As String
' Define apostrophe from good ol' ASCII number
Dim vApostrophe As Char = Convert.ToChar( 39)
' Double up any apostrophes
Dim vOutput As String = pStringToBeSQLd .Replace(vApost rophe, vApostrophe
& vApostrophe)
' Add apostrophes to each end of the string
Return vApostrophe & vOutput & vApostrophe
End Function
Usage;
Dim vName As String
Dim vSQL As String
vName = "Grim"
vSQL = "SELECT * FROM myTable WHERE myWhereClause=" & MakeSQLString(v Name)
& ";"
.... <query DB>
_______________ _______________ ___
The Grim Reaper
"Meyer1228" <ka***@ecsnj.co m> wrote in message
news:HQ******** **********@nwrd dc02.gnilink.ne t... You all helped me with function keys last week. Thanks so much; your
advice was right on.
My question now - does anyone have a function that I can use to test my
sql statements for the apostrophe and quote and do a search/replace type
thing. I'd like something to put in my basFunctions module instead of replacing
every time I do a sql command in my program code. Thanks!