Re: SQL SELECt with ' in filter name



Khalid Rahaman wrote:
I am trying to filter a recordset using the following SQL statement

SELECT * FROM 'cars.sold' where seller='" & txtSellername.text & "'"

the txtsellername.text refers to a texbox on the VB form which enters
the name i want to filter by.

This works great for everything except when the variable contains an
' in the textbox for example "Joe's Auto".

Any help would be appreciated.

While the other suggestions for doubling up the quote will indeed work,
IMO it is easier and more secure to use parameters, either via stored
procedures (my preference) or buy utilizing parameter markers in
conjunction with an array of parameter values passed via a Command
object. Let me know if you wish me to expand on this.

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


.



Relevant Pages

  • Re: SQL SELECt with in filter name
    ... the txtsellername.text refers to a texbox on the VB form which enters the ... name i want to filter by. ... Stephen Howe ...
    (microsoft.public.data.ado)
  • Re: SQL SELECt with in filter name
    ... the txtsellername.text refers to a texbox on the VB form which enters the ... name i want to filter by. ... the textbox for example "Joe's Auto". ...
    (microsoft.public.data.ado)
  • RE: Firewall Configuration for SMTP
    ... if I create one filter allowing SMTP ... > Microsoft CSS Online Newsgroup Support ... > This newsgroup only focuses on SBS technical issues. ...
    (microsoft.public.windows.server.sbs)
  • Re: FileWriter :: Change file wile the graph is running
    ... Nobody has assent that thore would maybe use this product. ... > extended quote from a non-MVP on the subject from this newsgroup in case ... > with this problem is to write a split graph filter. ...
    (microsoft.public.win32.programmer.directx.video)
  • RE: VBscript Error on SBS2k3
    ... I am working on the issue and it may cause some delay for your response. ... This newsgroup only focuses on SBS technical issues. ... you may want to contact Microsoft CSS directly. ... The filter settings are as follows: ...
    (microsoft.public.windows.server.sbs)