🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #12010

Re: VB + SQL probleem

#12010
From: KLinZ
Date: Fri, 28 Dec 2001 11:54
29 lines
1730 bytes
"Nico Vermandele" <nico.vermandele@pandora.be> wrote in message
news:NMKW7.530$Mq4.109657484@hebe.telenet-ops.be...
> Hallo,
>
> ik heb in VB het volgende gecodeerd:
>
> Set rs = db.OpenRecordset("SELECT * FROM klanten " _
>             & "WHERE naam like '*" + txtKlant.Text + "*'" _
>             & "order by naam;")
>
> als ik nu in txtKlant een string ingeef met een ' (weglatingsteken) in
krijg
> ik een error in het programma.
>

Zo werkt het wel:

strSQL = "SELECT * FROM klanten " _
             & "WHERE naam like '*" + txtKlant.Text + "*'" _
             & "order by naam;"

Replace(strSQL, "'", "''")

 Set rs = db.OpenRecordset(strSQL)

M.a.w. Alle quotes worden vervangen door 2 quotes.

Joris.
Technical Details
Message-ID: <a0hmk9$l0f5l$1@ID-79907.news.dfncis.de>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!c71152.upc-c.chello.NL!not-for-mail
References: <NMKW7.530$Mq4.109657484@hebe.telenet-ops.be>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: 107324,316450d5650606d2
X-Google-Attributes: gid107324,public
X-Google-Thread: fcea4,316450d5650606d2
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2001-12-28 03:55:56 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!c71152.upc-c.chello.NL!not-for-mail
From: "KLinZ" <klinz@hetnet.nl>
Newsgroups: be.comp.programming,nl.comp.programmeren
Subject: Re: VB + SQL probleem
Date: Fri, 28 Dec 2001 12:54:11 +0100
Lines: 35
Message-ID: <a0hmk9$l0f5l$1@ID-79907.news.dfncis.de>
References: <NMKW7.530$Mq4.109657484@hebe.telenet-ops.be>
NNTP-Posting-Host: c71152.upc-c.chello.nl (212.187.71.152)
X-Trace: fu-berlin.de 1009540553 22035637 212.187.71.152 (16 [79907])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000