Help with sql syntax in asp
am 04.08.2005 15:10:35 von iam247
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") &"' "
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.
Thanks Colin
Re: Help with sql syntax in asp
am 04.08.2005 15:48:08 von McKirahan
wrote in message
news:1123161035.880346.57790@o13g2000cwo.googlegroups.com...
> 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") &"' "
>
> 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.
>
> Thanks Colin
>
Try:
strSQL = "SELECT * FROM qryGroupContactDetails WHERE GroupID <> " &
rsContactID("ContactID") & " AND GroupName = '" & Request.Form("GroupName")
& "' "
What is your database type and version.
Re: Help with sql syntax in asp
am 04.08.2005 16:09:19 von reb01501
iam247@gmail.com 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.
Re: Help with sql syntax in asp
am 05.08.2005 01:04:00 von iam247
Hi McKirahan
Thanks for the reply - I will check it tomorrow.
DB = MS access 2002
Thanks ColinK
McKirahan wrote:
> wrote in message
> news:1123161035.880346.57790@o13g2000cwo.googlegroups.com...
> > 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") &"' "
> >
> > 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.
> >
> > Thanks Colin
> >
>
> Try:
>
> strSQL = "SELECT * FROM qryGroupContactDetails WHERE GroupID <> " &
> rsContactID("ContactID") & " AND GroupName = '" & Request.Form("GroupName")
> & "' "
>
> What is your database type and version.