DataSource Controls :: Get Calculated Field Into SQL?

Jan 14, 2011

At the top of my form I have some code that calculates a field

[Code]....

In my form I have this code. What changes below do I need to make to have the value of Date in XXXX?

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:sqlConnection %>"
SelectCommand="SELECT NumPeople, Date1,Time1,Venue FROM People_Count WHERE ((Date1=@ArvDate and Time1 >= '06:00:00.000') or (Date1=XXXX and Time1 <= '06:00:00.000')) and Venue='F & B' ORDER BY Date1 ASC, Time1 ASC">
<SelectParameters>
<asp:QueryStringParameter Name="ArvDate" QueryStringField="ArvDate" />
</SelectParameters>
</asp:SqlDataSource>

View 2 Replies


Similar Messages:

DataSource Controls :: SUM Function On A Calculated Field Does Not Work SQL 2005?

Mar 20, 2010

I have a simple query on a table to calculate the sum of a field (This field is a calculated field from within SQL 2005)SELECT SUM(RunTime) AS TotaL FROM TimeSheets.It errors out with: Error Message: Operand data char type char is invalid for sum operator.If I use the MAX or MIN function, no isssues. The data in this field is numeric.

View 4 Replies

Forms Data Controls :: Calculated Field Sorting Now Working?

Oct 1, 2010

although i had to take the table that has my calculated column and make a view (so i could filter) and then bind the gridview to the view.

My question is as this.

1.) in order to get my calculated field i had to load my data into a table (as suggested)

2.)Add a column to the table and perform calculations

3.)make a dataview from the tables because i could not get the Gridview.datasource= ds.tables("loads").select("Deadhead <= " & sngRadius

4.)the largest of the 3 tables my query is based on contains about 7000 records. The way i have the logic & programming now everytime a new "truck location" is put in the textbox1 and "find loads/button1" is clicked. It calculates the deadhead miles of all 7000 records before filtering. I am filtering based on the deadhead miles.

Does anyone have any recomendation about how to speed this up a bit.

Also in order to get paging to work i had to rebind/filter the data again ... means looping through all 7000 records each time paging is called. This seems terribly ineffecient as i am already forced to use access instead of SQL.

Would i see a performance increase if i installed SQL or mySQL and create linked tables to the ones i use in access. or would access still be the bottleneck?

I don't know if the performance increase would be negligible as i still ultimately be getting the data from Access.

I have posted the entire code for the page below. When i originally started i didn't think there would be to much code so i left it all on one page instead of using code-behind. Would i gain anything by swapping to code-behind now?

[Code]....

View 2 Replies

Forms Data Controls :: Adding A Calculated Field To A Databound Control?

Oct 19, 2010

I'm using a gridview to extract a set of records. I need to add another field to the gridview, which can calculate the difference between a date associated with each record and the current date.

View 6 Replies

ADO.NET :: Calculated Field In Select Statement?

Feb 3, 2011

I thought this would be easy but cannot now find out of to do it. All I want to do is execute an sql query on a table and in addition to the table's columns I want to also select/output a field that is calculated within the query. The table has a column "Owner" and I want to compare this to the UserId to produce a bool column "mine". Effectively doing:Select *, (Owner=@UserId) as mine where.....however, this doesn't work so how can I calculate a column in the select statement?

View 3 Replies

WebMatrix :: Calculated Field (column) In WebGrid

Dec 15, 2010

Is there a way to have a calculated column (field) in a webGrid in webMatrix?

View 4 Replies

DataSource Controls :: Data Types For Derived Or Calculated Columns?

Apr 26, 2010

I spent an hour googling and trying. No success. I want to get the digits behind the dot or comma for my calulcated column:

[code]...

But it just shows me a 0 and no other digits.

View 2 Replies

DataSource Controls :: DataTable Calculated Columns - "Total" Comes Out Blank

May 14, 2010

I am having problem with calculated columns in the following code

[Code]....

orderDT is the DataTable. When "Extra" column has nothing (I am NOT using Default), "Total" comes out to be blank? "Price" will have a value (always) "Extra" may not have any value

View 7 Replies

DataSource Controls :: Ignore Empty Field Because Always Join The Field And Separate By Space

Mar 3, 2010

I wanna join all the field as a new col.

but how can i ignore the empty field because i always join the field and separate by space like the following.

select (field_1+' '+field_2+' '+field_3) as new_col from TABLEA

but if the field is empty, then there is the double space

how can i ensure all the space is one space only.

View 2 Replies

DataSource Controls :: Set Field As DBNull.Value If Field Is Blank?

Apr 7, 2010

I have a 20 to 30 fields on a form. Most of them are optional. However, the users can fill out what they want. If a user dosen't fill in a field when data is sent to the database it's sent as blank, instead of NULL. Is there a way I can generically say "for all textboxes if Equals("") then DBNull.Value". Without going through each and every textbox?

View 2 Replies

Forms Data Controls :: How To Get Fields Calculated Before They Get Displayed

Jul 27, 2010

I'm a college intern at a small software company. I'm a novice when it comes to ASP.net and Expression Web, so sorry if these are obvious questions.

1. After figuring out how to get fields calculated before they get displayed (did this with SQL), I need to find a way to put certain characters before the output in the fields. I'm fairly certain this is done with a template field, but I have no idea how to touch those without making them blow up.

2. I would also like to have color in the GridViews rows or cells depending on a value returned from the database. Again, I think this would be done with template fields.

3. Thirdly, I need to be able to limit the characters in a few cells. I've searched and found some answers with this, but still Template fields go right over my head.

View 7 Replies

Forms Data Controls :: Use Sorting On Calculated Column?

Dec 1, 2010

Split off from http://forums.asp.net/t/1595139.aspx:

I have an additional column called 'KPI %' in my gridview that calculates the percentage of two template fields and thus I cannot use the sortexpression on it. How can I sort the contents of the 'KPI %' column in ASC or DESC format?

View 1 Replies

Forms Data Controls :: Display Calculated Value In Gridview?

Jul 7, 2010

I have 2 amount columns (Amount and TotAmount) in my gridview. In Amount column data comes from database. I want to display the total of amounts in Amount column in my TotAmount column (So there would be just one value in TotAmount column irrespective of the number of columns in Amount column). How can I do this.

View 18 Replies

Forms Data Controls :: How To Add Calculated Fields On A Gridview

Jul 21, 2010

My gridview displays fields from a table and allows for edit, delete and insert. I need to add a column with a derived field which will be calculated every time the user is either entering a new row or editing the value of the weight field which is one of the fields of the gridview. This calculation is done in the fly and won't be saved in the database.

View 8 Replies

Forms Data Controls :: How To Sort A Gridview By A Calculated Column

May 25, 2010

Is there a way to Sort a Gridview by a Calculated Column? I have a gridview with template fields using lablels and a linq datasource. Those columns sort just fine. I can not get the Calculated column to sort, because there is no sort expression to use...

View 4 Replies

Forms Data Controls :: Calculated Fields For All Of The Rows Is Blank

Jun 22, 2010

I have a GridView bound to an ObjectDataSource. Most of the columns are directly databound, however one column is not - it's value is determined in code. The value is being calculated correctly at the RowDataBound event, however when there is more than one data row in the GridView, the calculated fields for all of the rows is blank, but the top row displays the bottom row's calculated field

View 2 Replies

Forms Data Controls :: Sorting By Calculated Templatefield In Datagrid?

Sep 28, 2010

I have tried several different approaches .SOMEONE PLEASE sow me how to sort on template field with a calculated value.Basically i have half the data i need in the DB and the other half comes from textbox1.textI take the text in textbox1 and pass it along with a value from the DB (Orig) to a function that returns miles.

[Code]....

Whit the above method everything displays correctly but i cannot sort on that column .I also tried using the miles() function in my select statement for my datasource but that was a nightmare and couldn't get that to work i either got "undeclared function "miles()" or when i fixed that i got "orig" not declared.Sorry code is so jumbled , entire code is below:

[Code]....

View 15 Replies

Forms Data Controls :: How To Create Calculated Column Using Boundfield In Gridview

Oct 16, 2010

how to create calculated column using boundfield in gridview?

i want to create a new column using the existing records?

View 4 Replies

Forms Data Controls :: How To Create Calculated Column With Gridview Boundfield

Oct 17, 2010

how to create calculated column with gridview boundfield?

View 2 Replies

Forms Data Controls :: Adding Calculated Fields To A Databound Control?

Oct 14, 2010

I need a form that displays three columns drawn directly from a database (no problems here) as well as two fields that require some complex calculations. Not only am I lost as to how to incorporate the calculations into the control, I don't know exactly how to write the calculations. I am working in Visual Web Developer 2008 with Vb.NET.

The first of the two fields should take the sum of all payments made by a given customer and divide it by a DailyMembershipRate, returning a DaysPaid variable. It should take this variable and a CustomerSince field for that particular customer and calculate a PaidThrough field.

The second of the two columns similarly requires the DaysPaid variable described above. It should subtract the CustomerSince field from the current date and return the value in days, giving a MembershipDays variable. Finally, it should subtract MembershipDays from the DaysPaid variable, again returning a value in days, and then multiply this by the DailyRate value for a Credit/Deficit field.

I realize this is a lot, but I haven't been able to find any documentation either online or in VWD or ASP.NET texts on this topic. I could really use some fellow user input.

View 4 Replies

DataSource Controls :: Update Field In Db?

Mar 14, 2011

I am facing problem in my update statement,

Dim abc As String
abc = Request.QueryString("str")
Dim userName As String = CStr(Session("user"))
Label2.Text = userName
Dim MyConnection As New OdbcConnection(ConnStr)
MyConnection.Open()
Dim MyCommand As New OdbcCommand
MyCommand.Connection = MyConnection
If MyCommand.CommandText = "Select userid from week where userid ='" & userName & "'" Then
MyCommand.CommandText = "Update week Set value = '" & abc & "' where userid ='" & userName & "'"
Else
MyCommand.CommandText = "INSERT INTO week (value, userid) VALUES('" & abc & "','" & userName & "')"
End If
MyCommand.ExecuteNonQuery()
MyConnection.Close()

View 18 Replies

DataSource Controls :: How To Split Field In Sql

Jan 24, 2010

I have field_1, the data format store in the field is about "Mary, Amy, Billy, Ma"

how can i extract the record that the field_1 has Mary.

I can't use the like'%Mary%' because it can extract 'Ma' too.

I would like to extract exactly Mary. or can i split the field_1 by ',' in sql?

View 3 Replies

DataSource Controls :: Why Value Of Id Field Lost In

Jan 22, 2011

I used sqldatasouce and storeprocedure to populate DetailView. I need update few tables by pass parameters to my storeprocedure. but some value always lost (most of them is keyfield). when I checked those value through sqldatasource_updating event they are null . How can I get the correct value?

<asp:ControlParameter ControlID="DropDownList1" Name="Fname"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList2" Name="Lname"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="eid" Type="Int32" /> <--? why become null
<asp:Parameter Name="Fname" Type="String" />
<asp:Parameter Name="Lname" Type="String" />
<asp:Parameter Name="Room" Type="String" />
<asp:Parameter Name="Active" Type="String" />
<asp:Parameter Name="bid" Type="Int32" />
<asp:Parameter Name="bname" Type="String" />
<asp:Parameter Name="vid" Type="Int32" />
</UpdateParameters>

View 4 Replies

DataSource Controls :: Hiding Field In SQL?

Mar 26, 2010

is there some language to add to SQL that will hide a field?

View 5 Replies

Forms Data Controls :: Combine Two Boundfields Into One Calculated Column To Display In Gridview?

Nov 10, 2010

i am trying to combine two boundfields into one calculated column to display in Gridview like:

[code]....

View 8 Replies







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