Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select statement problem

Author  Topic 

crtdude
Starting Member

13 Posts

Posted - 2010-03-15 : 08:35:32
I am having a bit of an issue trying to get the correct select statement in the code below and was hopeful one of the experts in this forum would be gracious enough to assist.

This is a snippet within a calendar based event display utility. A form page displays a pull-down for a month/year selection from the user. As originally constructed, it was only for use in one property location but we now have several. I wanted to be able to select by month/year for a specific property, so I added a column to the database named property and now need to add in an additional variable so I can get the correct events for a specific month for a specific property.

Any help would be greatly appreciated.

==========
'******** get event data ********
If GetRequest("user_admin") = "" Then

objCommand.CommandText = "select * from OMNINEEDTEST where" &_
" NDATE_MONTH in (0," & Month(objDate) & ")" &_
" and NDATE_YEAR in (0," & Year(objDate) & ")" &_
" order by NDATE_DAY"
Set objRS = objCommand.Execute

If GetRequest("view") = "yes" And GetRequest("admin_action") = "" Then
objCommand.CommandText = "select * from OMNINEEDTEST where" &_
" NDATE_MONTH in (0," & Month(GetRequest("date")) & ")" &_
" and NDATE_DAY = " & Day(GetRequest("date")) &_
" and NDATE_YEAR in (0," & Year(GetRequest("date")) & ")" &_
" or event_weekday = " & WeekDay(GetRequest("date")) &_
" or RecordID = " & GetRequest("RecordID")
Set objRS_view = objCommand.Execute
ElseIf GetRequest("view") = "yes" And GetRequest("admin_action") = "edit" Then
objCommand.CommandText = "select * from OMNINEEDTEST where" &_
" RecordID = " & GetRequest("RecordID")
Set objRS_view = objCommand.Execute
End If

End If
==========

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-03-15 : 11:19:27
Follow this link for information on how to help us help you:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -