/ Forside / Teknologi / Udvikling / VB/Basic / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
VB/Basic
#NavnPoint
berpox 2425
pete 1435
CADmageren 1251
gibson 1230
Phylock 887
gandalf 836
AntonV 790
strarup 750
Benjamin... 700
10  tom.kise 610
Quote(')-problem in SQL-string
Fra : Susan


Dato : 13-11-06 15:11

Hello,

I use a Access-db for a music-collection. Using SQL I can make

selections. I do this by using a Text-box.

The problem occurs when Text1.Text contains the character (') single

quote. Like in Sinaed O'connor or T'pau).

The code below makes clear while the problem occurs (syntax).

' ## ---
MyVar = "%" & Text1.Text & "%"

SQLstring = "SELECT * From Albums WHERE Titel LIKE '" & MyVar & "'

ORDER BY Albums.Titel ASC;"
' ## ---

What can I do? Do I have to do a searcha and replace on the

MyVar-value? If so, how? Or is there another solution.

Thanks,

Susan



 
 
preben nielsen (19-11-2006)
Kommentar
Fra : preben nielsen


Dato : 19-11-06 21:23


"Susan" <ark312@home.nl> skrev i en meddelelse
news:ej9udv$tjp$1@news1.zwoll1.ov.home.nl...
> Hello,
>
> I use a Access-db for a music-collection. Using SQL I can make
>
> selections. I do this by using a Text-box.
>
> The problem occurs when Text1.Text contains the character (')
> single
>
> quote. Like in Sinaed O'connor or T'pau).
>
> The code below makes clear while the problem occurs (syntax).

SQLstring = "SELECT * From Albums WHERE Titel LIKE '[tag]' ORDER
BY Albums.Titel ASC;"
SQLString = Replace(SQLString, "[tag]", "%" & Text1.Text & "%")


--
/\ preben nielsen
\/\ prel@post.tele.dk



Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408914
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste