This content has been marked as final. Show 2 replies
> before "SelectedPrimary.Open()" I would add...
> Response.Write SelectedPrimary.Source
> run the page and copy the code ( SELECT O.OfficeID, O.ShortOffice FROM
> tbl_Offices O WHERE OfficeID = 7 ) into Query Analyzer
> Is there a similar function to write out the code to a page for
> troubleshooting a Command Object query that is used in Dreamweaver CS3?
Unfortunately as far as I'm aware, with the command object and the parameters it uses you can't get the actual SQL that is submitted to the database, you can only get the SQL with the ? tokens where the values are supposed to be inserted. However, if you want to try to recreate the generated SQL, try something like the following. Look for this line of code:
Set Recordset1 = Recordset1_cmd.Execute
Just above it add the following (substitute your recordset name for Recordset1 below):
' Should work for Access and SQL Server, other DBs are questionable
Dim cmd : Set cmd = Recordset1_cmd
Dim cmdSQL: cmdSQL = cmd.CommandText
for each param in cmd.Parameters
val = param.Value
If(param.Type = 200) Then ' If text
val = """" & val & """"
If(param.Type = 135) Then ' If date
val = "'" & val & "'"
cmdSQL = Replace(cmdSQL, "?", val, 1, 1)
Response.Write(cmdSQL &"<br />")
Note this likely will only work with Dreamweaver parameters created within the Recordset dialog.
> Other than repeatedly filling out the 4 items (Name, Type, Value and Default
> value) over and over,
> how do you make the Command Object to use the same variable, several times in
> one query?
Within the Dreamweaver UI, that's the way you do it. If you want to do it in the code, you can copy and paste the parameter code above the recordset, change the name slightly, like appending 2, 3, then 4. Then you'd need to add an extra Parameters and update the "param1" to 2, 3, and 4.
| Extending Knowledge Daily : http://CommunityMX.com/
| Adobe Community Expert
Thanks for the code. It works great.