View Single Post
  #28 (permalink)  
Old July 5th, 2008, 03:50 PM
Old Pedant Old Pedant is offline
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

quote:Originally posted by frakey
 Greetings to all contributors,

Is it at all possible to somehow add your suggested coding into the SQL query part of this dialog box as apposed to inserting it directly into the code?
Yes, but...

You never showed us the "bare bones" code as created by DW before you started modifying it.

The closest we have is from the posting where you showed

WADANews_cmd.CommandText = "SELECT approvedFlag, category, id, memberId, postDate, title, userText FROM News WHERE If session("AccessLevel") = "1" then memberId = "" Else If session("AccessLevel") = "2" then memberId = session("UserID") End If ORDER BY postDate"
WADANews_cmd.Prepared = true

setQueryBuilderSource WADANews_cmd, WADbSearch1_whereClause, false

In point of fact, I almost *DID* modify that code first thing, but the last line there threw me: What the heck *IS* WADbSearch1_whereClause and what does that SUB setQueryBuilderSource do???

I could make a *stab* at *guessing* what *might* work. But it becomes really really a guess. Here goes...Code in blue is the original from your post. All other code is my added stuff.
Dim WADANews
Dim WADANews_cmd
Dim WADANews_numRows

Set WADANews_cmd = Server.CreateObject ("ADODB.Command")
WADANews_cmd.ActiveConnection = MM_conn_glen_STRING

Dim level, where, SQL
level = session("AccessLevel")
If TypeName(level) = "Empty" Then
    Response.Write "ERROR: session(AccessLevel) is EMPTY...using 0, *NON*-admin<br>"
    level = 0
End If

where = " WHERE memberid = " & CLNG(Session("UserID")) ' assume *NOT* an admin
' but if *IS* admin, then get rid of the where
If isNumeric(level) Then If CDBL(level) = 1 Then where = "" 

SQL = "SELECT approvedFlag, category, id, memberId, postDate, title, userText " _
    & " FROM News " _
    & where _
    & " ORDER BY postDate, memberid "
Response.Write "DEBUG SQL: " & SQL & "" & vbNewLine

WADANews_cmd.CommandText = SQL
WADANews_cmd.Prepared = true
Set WADANews = WADANews_cmd.Execute
WADANews_numRows = 0
Dim WADANews_1__numRows
Dim WADANews_1__index

WADANews_1__numRows = 10
WADANews_1__index = 0
WADANews_numRows = WADANews_numRows + WADANews_1__numRows
Notice that I got rid of the setQueryBuilderSource line. Since I have no idea what it is supposed to do--and since so far as I can see the code is complete, as is--it seemed safest to just kill it.