Re: Help with sql syntax in asp
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Thu, 4 Aug 2005 10:09:19 -0400
iam247@xxxxxxxxx wrote:
> Hi
>
> I really struggle with SQL syntax when using VBscript asp.
>
> The following statement works OK:
>
> strSQL = "SELECT qryGroupContactDetails.* FROM qryGroupContactDetails
> WHERE GroupName = '" & Request.Form("GroupName") &"' "
>
Assuming "qryGroupContactDetails" is a saved parameter query, what is wrong
with:
Set rs=createobject("adodb.recordset")
AdoCon.qryGroupContactDetails Request.Form("GroupName"), rs
?
> This was copied and modified from someone else's sql
>
> Group name is a string
>
> Is it possible to clean up this sql ie. remove some of the ' " &
> symbols.
>
> If not, can someone clarify what each of the ' " & are doing.
>
> My main problem: I have tried the statement below which gives a
> 'mismatch' error message, I have tried several alternatives.
>
> Could soemone fix it for me?
>
> strSQL = "SELECT qryGroupContactDetails.* FROM qryGroupContactDetails
> WHERE GroupID <> " (rsContactID("ContactID")) & " AND GroupName = '" &
> Request.Form("GroupName") &"' "
>
> ContactID is an Integer held in the rsContacts array.
You have an array named "rsContactID"? It looks like a recordset to me ...
especially since you're using a string to retrieve an element from it, which
would cause an error if it was an array.
>
What is wrong with
Set rs=createobject("adodb.recordset")
AdoCon.qryGroupContactDetails rsContactID("ContactID"), _
Request.Form("GroupName"), rs
Better yet, validate the values coming from the form before attempting to
send them to the database.
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.
.
- Follow-Ups:
- Re: Help with sql syntax in asp
- From: iam247
- Re: Help with sql syntax in asp
- References:
- Help with sql syntax in asp
- From: iam247
- Help with sql syntax in asp
- Prev by Date: Re: Help with sql syntax in asp
- Next by Date: Re: ASP Access and date problems
- Previous by thread: Re: Help with sql syntax in asp
- Next by thread: Re: Help with sql syntax in asp
- Index(es):
Relevant Pages
|