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.
| Author |
Topic |
|
rj_connor
Starting Member
2 Posts |
Posted - 2011-10-02 : 12:48:03
|
| Hi hope someone can help me out here, i'm new to SQL and asp.netI have a web page using asp.net linked to a SQL database.The page allows you to enter in a email address in to a text file and a date in another text filed and when the search button i clicked a SP runs and pulls back the mailbox store location for the user on that date and displays it in a gridview below.(this works fine)What i want to do is add a check box that will allow you enter in the email address as before, check the checkbox, leave the date filed blank click the search button and pull back all the mailbox store locations for that user and display them in the same gridview.I can't figure out how to get this to work any help would be great.InfoDB table has 5 rows called DN,mail,homeMDB,name,datecode for the SP is@address nvarchar(250),@date datetimeASSET NOCOUNT ON;BEGIN SELECT dbo.mbxlocation2.homeMDB FROM dbo.mbxlocation2 WHERE dbo.mbxlocation2.mail = @address AND dbo.mbxlocation2.date = @date END |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-02 : 13:52:17
|
just add in click event of checkbox code to make value of @date as null and then change procedure as follows@address nvarchar(250),@date datetimeASSET NOCOUNT ON;BEGINSELECT dbo.mbxlocation2.homeMDBFROM dbo.mbxlocation2WHERE dbo.mbxlocation2.mail = @address AND (dbo.mbxlocation2.date = @date or @date is null)END ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
|
|
rj_connor
Starting Member
2 Posts |
Posted - 2011-10-03 : 10:15:33
|
| Ok take that in to account hw about changeing the SP to (at a high level).If dbo.mbxlocation2.mail = @address AND dbo.mbxlocation2.date = @dateSELECT dbo.mbxlocation2.homeMDBFROM dbo.mbxlocation2ELSEIF dbo.mbxlocation2.mail = @addressSELECT dbo.mbxlocation2.homeMDBFROM dbo.mbxlocation2ENDNot sure if that is posiable but something like that might work. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-10-03 : 12:53:00
|
This perhaps?IF @date IS NOT NULLBEGIN SELECT dbo.mbxlocation2.homeMDB FROM dbo.mbxlocation2 WHERE dbo.mbxlocation2.mail = @address AND dbo.mbxlocation2.date = @dateENDELSEBEGIN SELECT dbo.mbxlocation2.homeMDB FROM dbo.mbxlocation2 WHERE dbo.mbxlocation2.mail = @addressEND |
 |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-10-03 : 13:12:20
|
| http://sqlinthewild.co.za/index.php/2009/09/15/multiple-execution-paths/--Gail ShawSQL Server MVP |
 |
|
|
|
|
|