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 |
s2002
Starting Member
49 Posts |
Posted - 2010-08-15 : 13:23:35
|
HelloI use Query string Value to filter DB records and bind result to GridView.Suppose I want to list all records for specific "CategoryName"Currently I use 2 queries . 1st query to check if Given "CategoryName" exist in DB and 2nd query is using Approved Query filter in main query.Could I merge this 2 queries in 1 query? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-08-15 : 13:28:37
|
you can. use if exists(select 1 from table where CategoryName=@YourParam) <your filter query>------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-15 : 13:29:41
|
Why do you need the first query?What are you doing if the first query returns no resultset?Can you do the same if the main query isn't returning a resultset? No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
s2002
Starting Member
49 Posts |
Posted - 2010-08-15 : 13:36:00
|
webfred, If It returns no result, then some other controls status will be changed. think about Label Control which shows the Querystring value in page. if Querystring value is not exist in DB I want this control to be invisible. |
|
|
s2002
Starting Member
49 Posts |
Posted - 2010-08-15 : 13:48:41
|
I use this style in webpage Page load event. I want to know if it is optimized Dim i As New GeneralClass If i.checkTypeExist(querytag) Then postlist.DataSource = i.GetListName(querytag) postlist.DataBind() Else '///// End If |
|
|
|
|
|