Re: Help with sql syntax in asp

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


.



Relevant Pages

  • Re: ADO - returning different results rather then Query analyzer !!!
    ... the various groups into the Newsgroup box, ... > From the sql server query analyzer i got results as a nameless column ... > I took the SAME sql syntax and opend an ADO.Recordset using VB: ...
    (microsoft.public.access.externaldata)
  • Re: COunting database entries
    ... Or put teh table results in an array and count them that way with PHP. ... that SQL syntax may not be correct, but I think it's close, ... The database records your info. ...
    (alt.php)
  • Simple question on arrays and sql
    ... Given that I have a 2D array in php, is there a sql syntax to insert the entire array at once? ... For example if I retrieve a set of data from one table in the database with keys A, B and C, and suppose there are 100 records, and I build an array $arr consisting of ... Of course for Oracle I could do the same and only do a commit after all are done. ...
    (comp.lang.php)
  • Re: Strange issue
    ... You have an error in your SQL syntax; ... that corresponds to your MySQL server version for the right syntax to ... the $points array yet it is not showing $cpid for the golferId. ...
    (comp.lang.php)
  • Re: Strange issue
    ... You have an error in your SQL syntax; ... that corresponds to your MySQL server version for the right syntax to ... the $points array yet it is not showing $cpid for the golferId. ...
    (comp.lang.php)