0
Reusing recordset variable parameters

/t5/dreamweaver-discussions/reusing-recordset-variable-parameters/td-p/645163
Feb 27, 2007
Feb 27, 2007
Copy link to clipboard
Copied
Sorry for the double post guys but I've had no luck in the
general forum. Please help me find an answer to this.
--------------------------------------
I've been trying to reuse recordset variable parameters but when I try it get:
<variable>
"is an invalid variable name, it does not appear in the SQL"
Here is the SQL:
SELECT [Client Record ID], [Client Initials], Age, Sex, [Surgery AKA], [Referrer name], Comments, [Date referral made], [Counsellor First Name], [Counsellor Surname]
FROM dbo.[SYS New Referral Registration Record]
WHERE ([Client Record ID] = varClient AND [Counsellor Code] = varCounsellor) OR ([Client Record ID] = varClient AND [Owner] = varCounsellor)
.....................................
The variables are specified correctly but it won't use it more than once. When I refer to the varible once it works fine.
Any ideas???
--------------------------------------
I've been trying to reuse recordset variable parameters but when I try it get:
<variable>
"is an invalid variable name, it does not appear in the SQL"
Here is the SQL:
SELECT [Client Record ID], [Client Initials], Age, Sex, [Surgery AKA], [Referrer name], Comments, [Date referral made], [Counsellor First Name], [Counsellor Surname]
FROM dbo.[SYS New Referral Registration Record]
WHERE ([Client Record ID] = varClient AND [Counsellor Code] = varCounsellor) OR ([Client Record ID] = varClient AND [Owner] = varCounsellor)
.....................................
The variables are specified correctly but it won't use it more than once. When I refer to the varible once it works fine.
Any ideas???


TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/reusing-recordset-variable-parameters/m-p/645164#M185845
Feb 27, 2007
Feb 27, 2007
Copy link to clipboard
Copied
Ding_Dong wrote:
> WHERE ([Client Record ID] = varClient AND [Counsellor Code] =
> varCounsellor) OR ([Client Record ID] = varClient AND [Owner] =
> varCounsellor)
If it is mssql you need more brackets as below
> WHERE (([Client Record ID] = varClient) AND ([Counsellor Code] =
> varCounsellor)) OR (([Client Record ID] = varClient) AND ([Owner] =
> varCounsellor))
--
> WHERE ([Client Record ID] = varClient AND [Counsellor Code] =
> varCounsellor) OR ([Client Record ID] = varClient AND [Owner] =
> varCounsellor)
If it is mssql you need more brackets as below
> WHERE (([Client Record ID] = varClient) AND ([Counsellor Code] =
> varCounsellor)) OR (([Client Record ID] = varClient) AND ([Owner] =
> varCounsellor))
--
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/reusing-recordset-variable-parameters/m-p/645165#M185846
Feb 27, 2007
Feb 27, 2007
Copy link to clipboard
Copied
There's actually a bug in DW's new recordset code. When you
re-use a
parameter, it only attaches the parameter one time. If you were to look in
code view, you'd see something like:
myCmd.Source = "SELECT ... WHERE this = ? AND that = ? AND (here = ? OR
there = ?)"
This means you'll need to see 4 parameters attached, one for each question
mark. To re-use a variable, copy and paste the line that attaches the
variable into the appropriate position (the first parameter attached goes
with the first question mark and so on). You'll have to change the name
slightly (for instance, from "@varClient" to "@varClient1") to avoid errors
that say the parameter already exists in the collection.
"Ding_Dong" <webforumsuser@macromedia.com> wrote in message
news:es19s7$e6l$1@forums.macromedia.com...
> Sorry for the double post guys but I've had no luck in the general forum.
> Please help me find an answer to this.
>
> --------------------------------------
>
> I've been trying to reuse recordset variable parameters but when I try it
> get:
>
> <variable>
>
> "is an invalid variable name, it does not appear in the SQL"
>
> Here is the SQL:
>
> SELECT [Client Record ID], [Client Initials], Age, Sex, [Surgery AKA],
> [Referrer name], Comments, [Date referral made], [Counsellor First Name],
> [Counsellor Surname]
> FROM dbo.[SYS New Referral Registration Record]
> WHERE ([Client Record ID] = varClient AND [Counsellor Code] =
> varCounsellor)
> OR ([Client Record ID] = varClient AND [Owner] = varCounsellor)
>
> .....................................
>
> The variables are specified correctly but it won't use it more than once.
> When I refer to the varible once it works fine.
>
> Any ideas???
>
>
parameter, it only attaches the parameter one time. If you were to look in
code view, you'd see something like:
myCmd.Source = "SELECT ... WHERE this = ? AND that = ? AND (here = ? OR
there = ?)"
This means you'll need to see 4 parameters attached, one for each question
mark. To re-use a variable, copy and paste the line that attaches the
variable into the appropriate position (the first parameter attached goes
with the first question mark and so on). You'll have to change the name
slightly (for instance, from "@varClient" to "@varClient1") to avoid errors
that say the parameter already exists in the collection.
"Ding_Dong" <webforumsuser@macromedia.com> wrote in message
news:es19s7$e6l$1@forums.macromedia.com...
> Sorry for the double post guys but I've had no luck in the general forum.
> Please help me find an answer to this.
>
> --------------------------------------
>
> I've been trying to reuse recordset variable parameters but when I try it
> get:
>
> <variable>
>
> "is an invalid variable name, it does not appear in the SQL"
>
> Here is the SQL:
>
> SELECT [Client Record ID], [Client Initials], Age, Sex, [Surgery AKA],
> [Referrer name], Comments, [Date referral made], [Counsellor First Name],
> [Counsellor Surname]
> FROM dbo.[SYS New Referral Registration Record]
> WHERE ([Client Record ID] = varClient AND [Counsellor Code] =
> varCounsellor)
> OR ([Client Record ID] = varClient AND [Owner] = varCounsellor)
>
> .....................................
>
> The variables are specified correctly but it won't use it more than once.
> When I refer to the varible once it works fine.
>
> Any ideas???
>


>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/dreamweaver-discussions/reusing-recordset-variable-parameters/m-p/645166#M185847
Feb 27, 2007
Feb 27, 2007
Copy link to clipboard
Copied
Thanks for the reply but I still get the invalid column names
error when using the same variable twice. If I did this in
Dreamweaver MX 2004 I know it works.
I have triple checked the columns and their names.
Anything else - keep them coming.
I have triple checked the columns and their names.
Anything else - keep them coming.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

