SQL Server :: Method To Choose Where To Place If Condition For Query

Jul 15, 2010

I have a table with 3 fields, catCode, startDate and endDate. I am having trouble deciding how to query my DB based on the following. By default a gridview will return all records that match the catCode selected from a dropdown list. If the user checks a check box, only records are returned where.

startDate <= today AND endDate >= today

How can I apply the If condition to compare when the check box is selected? I used the wizard to build the select statment for the gridview, but I can switch that to a SP if that makes life easier.

View 8 Replies


Similar Messages:

SQL Server :: Query Method For Adding Records

Jan 12, 2011

auton=createsid(num)
INSERT INTO Store_Information (sid,store_name, Sales, Date)
SELECT store_name, Sales, Date
FROM Sales_Information

in the baove i need to add the SID which is a no obtained from incrmenated function, how do i add itautono will contain the incremnet value which i need to add to sid column

View 18 Replies

C# - How To Add A Condition String To An Sql Query In An Var Type

Aug 27, 2010

Im working on an source code with an sql query in a VAR type like var query = select ... from ... where ... ; is it possible to add an dynamic "where clause" like string condition = "where x.x > x.y"; e.g. var query = select ... from ... + condition;

View 2 Replies

DataSource Controls :: Implementing A BLL / Contacts Table, The Select Method Is A Sql Query Against A Sql Server 2000 Database?

Feb 17, 2010

I'm implementing a BLL layer and have a few questions. First, in my DAL, there is a contacts table, the select method is a sql query against a sql server 2000 database. The preview data returns everyting as expected. The query is

[Code]....

The BLL method is built like so

[Code]....

When using the BLL method to a gridview, the results of the subquery are not displayed. There are also other methods, each having a different where clause for ContactRole_ID and each is having the same issue of not displaying the subquery reult in the gridview. No error, but no data is displayed for the subquery either. Here is the templatefield of the gridview

[Code]....

Another item that is causing an error is in trying to update a record. Here is the DAL update method

[Code]....

And the BLL update method

[Code]....

The error says i have extra parameters, but have no clue where the extra parameters are being picked up. The error isObjectDataSource 'odsContacts' could not find a non-generic method 'UpdateContact' that has parameters: _ContactID, _Active, _ContactName, _Office, _VirtualOffice, _Pager, _Fax, _Home, _Cellular, _Email, _ContactRole_ID, Active, ContactRole_ID, ContactName, Office, Email, VirtualOffice, Pager, FAX, Home, Cellular.And the objectdatasource

[Code]....

View 4 Replies

Web Forms :: Forming Query Based On Condition For Displaying Records In Grid On Demand

Feb 22, 2012

I have a function or binding grid where i pass the flag for query to be displayed for page load i have below query

if (flag=="pageload){sql= "select  ";  sql= sql *  "  from (select top  50   *  "  from ";   
sql= sql+ "(select top  50  *   from EMPLOYEE  order by NAME )"; 
sql= sql+ " as T1 order by T1.NAME  DESC) as T2 order by NAME  ASC  ";
} else if flag=="filteration select * from EMPLOYEE

In the above query i get 50 records per page & the next prev navigation works fine but when i filter out the records  i cant use the above query to get the filtered records as I need to filter from the whole recordset say I have total 1000 records after filtering i get 500 records after filtration i am not able to navigate across the records correctly...

View 1 Replies

SQL Server :: Choose The Most Popular Venue?

Jan 21, 2011

i have to choose the most popular venueselect max(count(Destination))as popular_venu from bookingthis shows me error.how do i solve this?nothr queriesselect max(count(Departure_time)from bookingwhere Departure_time>12:00:00i got error for both.please help me to sovle

View 5 Replies

Web Forms :: Append CustomPrice To The Current Page's Query String Before The Response.Redirect Takes Place

Apr 25, 2010

I have a page that is used to add info from a gridview into a user's profile. I have explained my issues after all of the code. Here is the applicable code(s) involved:

Protected Sub AddToCart(ByVal sender As Object, ByVal e As CommandEventArgs)
For Each gvr In GridViewItems.Rows
Dim txtGiftAmt As TextBox = (CType(gvr.FindControl("txtGiftAmt"), TextBox))
If txtGiftAmt.Visible = True Then
Dim customPrice As String = txtGiftAmt.Text.ToString
'HERE is where I would like to set the new price variable value somehow
End If
Next
Dim scart As New ShoppingCart
scart.AddCartItem(e.CommandArgument.ToString())
Response.Redirect("~/ShoppingCart.aspx")
End Sub

This sub is called by the following button when clicked:

[Code]....

Here is the sub from the ShoppongCart Class named AddCartItem:

[Code]....

Here is the problem that I am having: I have one specific item that allows user's to define their own price (for this item only). By putting this price in a session variable seems to be the easiest way to handle this (at least for me), but the session variable's value always "lags behind". By this I mean that the first time the items is entered, it uses the default value of cartItem.ItemPrice. The second time the same item is added (with the intention of a different price), this new item's cartItem.ItemPrice is set
as the first session("customPrice").

Because the user is selecting his/her own price for this item, I am not worried about lack of security involved with using query string to pass this price, but I can't get the string passed to the ShoppingCart class correctly (shows up null). Is there a way to append this customPrice to the current page's query string before the Response.Redirect takes place? If I understand this correctly, the Response portion "posts back" to the current page before the Redirect sends us on our merry way, right?

View 3 Replies

Forms Data Controls :: Datagrid With Column Choose To Choose Columns Dynamically Using DataGrid With Object Data Sour

Sep 30, 2010

I have "Order" object with Columns Ticket,OTP and CustomerName etc.Intially on DataGrid, I'm binding Ticket only , when user clicks on "Column Chooser" button, another windows appears to pickup CustomerName,OTP columns to add specified column dynamically on Datagrid. Environment : Asp.net ,C# with Object Data source

Public Class Order
{
publc void Order()
{
}
public string Ticket
{
get
{
return this.strTicket;
}
set
{
this.strTicket = value;
}
}
public string OtpNumber
{
get
{
return this.strOtpNumber;
}
set
{
this.strOtpNumber = value;
}
}
public string CustomerName
{
get
{
return this.strCustomer;
}
set
{
this.strCustomer = value;
}
}
}
}

View 1 Replies

DataSource Controls :: Fetch Record Using Join Query When One Join Condition Is True?

Feb 18, 2010

To write a join query with or condition. It means a query has two inner join, here it is possible to fetch the records, if one inner join is true and other is false. I got a record when only two join conditions are true.

View 1 Replies

Jquery And Updatepanel : Binding Jquery Method At A Common Place?

Mar 17, 2011

I am using multiple user control in my web page. Each of these usercontrol has $(document).ready() method. Because i am using an update panel, i am binding all the events again in end_request event. But I dont want to do that in all my usercontrols. Is is possible to do this at a common place(only once)?

View 1 Replies

SQL Server :: Pass A Value Into Procedure And Use As Condition?

Feb 7, 2011

I have a request that allows the end user the option to select a radiobutton with the following values;

>= or <=

and then provide a numerical value in textbox So i would like to know if i can pass in 2 parameters to the procedure.. so that my where statement is built based on the inputs from the user.

Example would be

@conditionvalue
@numericalvalue
SELECT *
FROM mytable
WHERE column1 @conditionvalue @numericalvalue

Whats the best way to accomplish this.. the statement is pretty simple, selecting a few columns and 2 where conditions, the one above and another parameter.

View 13 Replies

SQL Server ::set Condition With Union All Commands?

Mar 25, 2011

Below is my SQL query in which I have used UNION All In my outer query.so I want to select data onwards particulardate. [code]...

View 1 Replies

Web Forms :: How To Update Server Processing Condition To Client

Oct 15, 2010

My scenario is that when a user clicks a link to download a file, a large file will be downloaded. But many files are zipped and to become a requested large file, files are needed to be unzipped at the server side and download it. Meanwhile unzipping the files, I wanna show to the user how many percent of files have been unzipped.

So, I save the current condition of % into the session () and it has been updated accordingly and in the other page session is called using the iframe to be seem as they are in the same page. But the problem is that,

while updating the iframe with update pannel and timmer tick event doent work and only when unzipping process has done, it works.

View 1 Replies

Where To Place Temporary Files In Server

Jun 24, 2010

my aspx web app needs to allow clients to load files (excel files) to some place in the server, to be able to open and read content via OLEDB immediataly after upload. Are there any "best practices" or suggestions about location, naming and security of temporary files folders? Also I need these files to be automatically deleted after use, I would like to be sure they always are. VS 2008/ .net 3.5 framework/ Windows server 2003 and 2008

View 2 Replies

How To Invoke Server Method When Asynchronous Method Is Complete

Jul 27, 2010

I have jQuery plugin - progress bar. How to invoke server side method on success? The code is below:

(Everything works fine)

[Code]....

View 1 Replies

DataSource Controls :: Can't Find Query's / By Right Clicking On Database Created A Query In Server Explorer?

May 17, 2010

By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.

View 10 Replies

SQL Server :: Sub Query In Cross Table Query To Create Statistics

Mar 2, 2011

I am trying to create statitics for game downloads and am having dificulty with a sub part of my query. the goup by command is not having the disired result and i think i have been looking at it too long to see what i am doing wrong. [Code]....

At the moment it is producing each result in many rows when only 4 rows should appear. its the download column that is doing it. needs to be sub queried or something to display total in relation to month,gameid,userid.

Month-download-GameID-UserID

1 1
1 1

1 1
1 1

View 2 Replies

SQL Server :: Query Slow In Loading / Trying To Display Query Result?

Feb 1, 2011

I am trying to display this query result in an aspx page.

It is very slow in loading. Here is the query. The inner query inside the outer quesry is the problem.(Please see the underlined part in the query) - (If I remove that part it is very fast.)

select

top 500

--This column is the issue
,Governing_Class=( case when exists (select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.appid and tqc.class_code not in('8742' ,'8810','7380')
order by tqcm.premium_amt desc
)
then ( select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.
appid
order by tqcm.premium_amt desc
)
......... From tables

View 7 Replies

AJAX :: Modal Popup Based On Server Side Code Condition?

Mar 31, 2011

How can I show an AJAX modal popup based on some code logic and NOT based on a button to be clicked? For example:

if (!User.Identity.IsAuthenticated)
{
Show a modal popup here which says: 'This process is only available to users who are logged into the system.'
}

View 3 Replies

How To Send A Hyperlink Using Query String Method

Aug 27, 2010

I want to send hyperlink by attach it with URL with the of query string method. For instance in a web page containing three links like

[URL]

now suppose user click on yahoo.com at this point i want to send it by attaching with url like [URL]......some thing like that

View 1 Replies

Error - Method 'First' Can Only Be Used As A Final Query Operation

Mar 16, 2011

I have the following query:

Dim roommates = From p In dbroom.Residents _
Where p.room = queryStudent.First.r.id _
Where p.building = queryStudent.First.b.id _
Where p.year = year _
Where p.semester = term _
Select p.person_name

It currently returns no results. I was getting an error when attempting to bind this resultset (since it was empty) to a repeater in ASP.NET, so I attempted to escape it:

If roommates.Count() = 0 Then
Dim nomates As String = "No current roommates."
rptrRoommates.DataSource = nomates
rptrRoommates.DataBind()
Else
rptrRoommates.DataSource = roommates
rptrRoommates.DataBind()
End If

But I still get the same error:

The method 'First' can only be used as a final query operation. Consider using the method 'FirstOrDefault' in this instance instead.

View 1 Replies

ADO.NET :: Field Method Missing With LINQ Query?

Sep 7, 2010

I want to access the data from datatable object. When i trying to get the fieldslist usng "Field" method. But I could not find the method with my table object. Eventhoguh i forcibly write a method and trying to access the fields, It is giving the below error for the first join in query. Rest of the lines are fine.

What is the reason behind it.

The errro: "Error 2 'LINQ2DB.SP_VS_OP' does not contain a definition for 'Field' and the best extension method overload 'System.Data.DataRowExtensions.Field<T>(System.Data.DataRow, string)' has some invalid arguments"

What is the meaningof the error. Shall i do any other changes in the query line?

var QueryChnl = from oSPOP in SPOP.AsEnumerable()
join oDiscChannel in DiscChannel.AsEnumerable() on oSPOP.Field<int>("spid") equals oDiscChannel.Field<int>("SPID")
join oChannel in Channel.AsEnumerable() on oDiscChannel.Field<int>("channel") equals oChannel.Field<int>("channelID")
where oSPOP.Mappingkey == 3200004
select new { oSPOP.Mappingkey, oChannel.channel, oDiscChannel.STATUS };

View 1 Replies

Databases :: Oracle Query Convert To Sql Server Query

Sep 3, 2010

I am a biggner in SQL DB . but i started a complicated and painfull work in SQL SERVER 2008. the problem convert Oracle hierarchical query to SQL query. the query

SELECT DISTINCT
LEVEL LVL,
SCH.NSCHEDULE_SL,
SCH.NSCHEDULE_SL_FM,
SCH.CSHED_CNAME
FROM FA_SCHEDULES SCH
WHERE LEVEL = 1
AND NSCHEDULE_SL_FM IS NULL
AND NBRANCH_SL = 2
CONNECT BY PRIOR SCH.NSCHEDULE_SL_FM = SCH.NSCHEDULE_SL
AND NBRANCH_SL = 2

View 1 Replies

How To Place Two Controls In The Same Place And Alternate Between Them

Apr 1, 2011

I want to place two datalist controls at the same (x,y) position. When the first is visible, second should be invisible.

How would I go about implementing this?

View 2 Replies

Error Showing The Place Of Origin To Be Local Instead Of Web Server?

Jan 7, 2010

I have a web server on which I deploy my asp.net project after publishing. However many times I have noticed that when any error occurs on the web server I see that the error location is showing path of my local machine on the webserver and not the path of the web server.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved