|
 |
asp_databases thread: asp-sql error
Message #1 by "Neetu Dhatt" <neetu_dhatt@h...> on Sat, 01 Feb 2003 01:26:51 +0000
|
|
I have the following code to check whether I already entered A Particular book and a author record before
strSQL= "select * from tblBook where Title like '"& strTitle&"' and Author like '"&strAuthor& "'"
m_BookRecordset.Open strSQL,Conn,1,3,1
. This code works fine until i enter a book or an author name with an apostrophe(') in it such as
O'cullingham
the apostrophe(') conflicts with the ' ' in the sql statement '"& strTitle&"' . if i enter this name in the eg. it will
give me error. Does anyone have a solution to this.
ThanksMSN 8 helps ELIMINATE E-MAIL VIRUSES. Get 2 months FREE*.
Message #2 by "Gillian Harber" <gillian@m...> on Mon, 3 Feb 2003 10:14:21 -0000
|
|
Two extra lines before will help:
strTitle = Replace(strTitle, "'", "''")
strAuthor = Replace(strAuthor, "'", "''")
Hope that helps
Gillian
----- Original Message -----
From: "Neetu Dhatt" <neetu_dhatt@h...>
To: "ASP Databases" <asp_databases@p...>
Sent: Saturday, February 01, 2003 1:26 AM
Subject: [asp_databases] asp-sql error
>
> I have the following code to check whether I already entered A Particular
book and a author record before
>
>
> strSQL= "select * from tblBook where Title like '"& strTitle&"' and Author
like '"&strAuthor& "'" m_BookRecordset.Open strSQL,Conn,1,3,1
> . This code works fine until i enter a book or an author name with an
apostrophe(') in it such as
> O'cullingham
> the apostrophe(') conflicts with the ' ' in the sql statement '"&
strTitle&"' . if i enter this name in the eg. it will give me error. Does
anyone have a solution to this.
> Thanks
|
|
 |