DataSource Controls :: Case Statement Assign Values Based On Condition?
Feb 2, 2010I need to modify the results (NULL) to reflect '0.00'.
My query statement is giving me an error at the CASE level.
[code]...
I need to modify the results (NULL) to reflect '0.00'.
My query statement is giving me an error at the CASE level.
[code]...
im doing a shopping cart for my website. And i want to do a conditional statement to check if the
custname and productcat is inside the shopping cart then i'll only insert/update the quantity of the product he purchased.
here's my code:
Protected Sub btnAddToCart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddToCart.Click
this is my select Statement.:-
Select (datediff(day,db_TargetDate,getdate())) from tbl_abc
in select statement only i wanted only those record in which datedifference is less than 5.
declaration of variable & then conditional checking is not wanted me because i wanted result is into select statement only & not using print statement.
I want to delete recodrs from based on some join condition between two tables.
One table belongs to my DB ( table name : FeeDetails)
and second table ( TargetTable) is on different server.
I have delete records from TargetTable table based on join condition between two tables.
I am able to select records
[Code]....
How can i check a parameter value and add onto or remove conditions from my where statement.Here is what i mean.. i have a stored procedure that is being used for returning small set of fields based on a parameter that it is expecting. Since the only difference between the select statements are the last AND condition, i was wondering if i can check that parameter as im doing now but change that AND condition so that i have only 1 select statement instead of 3 within my procedure.Current Example:
if @rptNum = 1
begin
Select * FROM tblName
[code]...
I am looking to cache a dataset and then filter the results as they will be used repeatedly. However, I don't know how to assign values in the filtered dataset to variables in C#. I have looked on the internet for the past few hours but all I can get in binding the dataset to a control.
View 4 Repliesi have to combobox which default selected value is "select all" and other values USA GERMANY vs.
and i have countries table.how can i query all country names when "select all" value is selected.My stored procedure is look like this
select * from countries where countryname=@prmcountryname
I have a select statement in a stored procedure and want to be able to retrieve the key column value (PRODUCTID)and return it as Output when Select statement is executed on input Parameter (NAME).
addition, return two further output values (COST,TOTAL).
note the grid control expects to receive all values at once! so i need to get out these values at the same instance of execution.
Select productID,COST,QUANTITY,NAME,TOTAL,DATE
FROM PRODUCTS
WHERE NAME=@NAME
I am having difficulty selecting data from 2 tables that do no share a primary key value. For instance, I have an actual table, a forecast table, and a GLText table. I may have an actual value but not a forecast value but I need them to appear in the same Query (like the query results shown below). I can get all values to appear in each table but have been unsuccessful in getting all values from both tables.
View 5 RepliesI am looking to retrieve data from a database and assign those values to class objects which in turn will be turned into session variables. I am using an object datasource to retrieve the data from the database but I cannot find anywhere that shows how to assign these values to variables. The data is returned in a dataset. There is the added problem that there will be mulitple items returned which will have to be assigned to different arraylists of objects based on the a primary key in the database.
View 4 RepliesI want to retrieve the full SQL that my Web Application generates and executes on the database. So when the INSERTED or UPDATED events are triggered on the SqlDataSource, I want to get that particular SQL Statement.
The problem I've got there though is when I use "e.Command.CommandText" that gets the SQL statement with the paramter names NOT the paramter values. I specifically need the values.
So... how can I get it to display the full SQL statement containing submitted values!?
This is my code so far:
SQL = "insert into " & tableNameToday _
& "(ID, Name, Calories, Of_Which_Fat, Protein, Carbohydrate, Of_which_sugars," _
& "Fat, Of_Which_Saturated, Of_Which_Monounsaturates, Of_Which_Polyunsaturates," _
[Code]....
how do i multiply the columns like this. for now static explanation would be ok but eventually i would like to make it dynamic so there would be a text box for users to enter the amout they like e.g 160g then the table would know to multiply the columns by 1.6.
why the case statement is never running
[Code]....
[Code]....
I have a database table with three columns of interest
slottypekey (integer)
taskkey (integer)
permission (string)
Lets's say I have a stored procedure that gets this data and puts it into a dataset.
I would like to write a function that has input parameters of slottypekey and taskkey
and that returns the associated permission. What is the best way to do this?
I have successfully created a strongly typed dataset. And trying to assign my user input values to the columns of my StronglyTypedDataset but having no luck with it
[Code]....
In the above code 'PlantInventoryAccuracy' is the name of the Strongly Typed Dataset and 'PlantInventoryAccuracyDataTable' is the dataTable. when I try o debug this to see if my user input values are being assigned to te currentRow I see blue squuiggly line under the 'new' key word when I mouse hover it says
'The type PlantInventoryAccuracy.PlantInventoryAccuracyRow has no constructors defined.'
This is the first time I am trying to use Storngly typed datasets. I am not sure if I am trying to use it right. The above code is in my code behind page and my idea is to fill this row with the user input values then pass this to my data layer where I need to assign these values as the parameters to the stored procedure I have created and then store them to the database.
How to Fetch Rows based on Values in a Session Variable
View 4 Repliesi trying following query Select
View 4 RepliesI have been working on a stored procedure to calculate likert scales for course evaluations. I have the stored procedure done but I ran into an interesting but frustrating situation.
I used a case statement along with a select query to count the number of responses of a given value. Likert scales are usually 5 point scales 5 being the highest and 1 being the lowest. The value that gave me the trouble was null values. In my evaluation page the instert query puts a null value in the field instead of leaving the response blank. These are the two queries I used both are syntactically correct but one works and the other doesn't. #1 Null query that works
[Code]....
Can anyone explain the differences and why one works but the other doesn't? Can it be as simple as switching the WHEN and the column name and if it is would it be advisable the other ones around?
I have an asp.net application that uses validation controls on textboxes. However, if the user enters a value in txtFieldA, then I want to disable the validation controls on txtFieldB and txtFieldC.
View 2 RepliesI want to higlight the background color based on condition
E.g. I have a column likeÂ
name    rate
rafi      100
ravi        0
karthick  300
Here rafi and karthick should display the background color
ravi should display the whitecolor
I am using a SP to insert into tables base on the parameters but getting syntax errors on:
Msg 156, Level 15, State 1, Procedure Dyno_InsertNewItem, Line 27
i want to get one value from function using case statement,i tried it but not work
CREATE FUNCTION [FATMS].[fnReturnByPeriod]
(
@Period INT
) [code]....
Working on a heavy ajax based site with over 100 methods from all the ajax calls inside each of each controller all with basically the same code.Was thinking of changing them to a big case statement for readability which would keep the code a bit more dry and make it easier to read.What I am wondering is: Will there be a performance hit and is there a better way to deal with it?
View 4 RepliesI created a function and am trying to access it through a case statement, but I am getting the error:
Cannot find either column "core" or the user-defined function or aggregate "core.f_FiscalYear_Open_Days", or the name is ambiguous.
The case statement is below:
CASE
WHEN c.program_id
= 5
and
CAST(minutes)
As
float)/60
>=
@MiddleSyTargetHrs
/core.f_FiscalYear_Open_Days(c.program_id,Org_Site_ID_Contract,'7-01-2009','7-31-2009')
Then 1
Else 0
End
As
mon_1_hrs
I have Gridview with column name END Date.
DATE is dd/mm/yyyy Format
Available data is :- START DATE = 1/1/2010 , STOP DATE = 1/4/2010 ,INTERVAL = 1 WEEK
HOw to bind data to gridview such that gridview should display data from 1/1/2010 to 1/4/2010 for the interval of 1week
THE OUTPUT SHOULD BE:-
[code]...