Group The Table According To The Month In The Table?

Mar 27, 2011

I need to group the table according to the Month in the table.

The query goes this way:

var query =
from a in db.Dates
from b in db.Facts
where a.Count_Key == b.Date_key
select new
{
a.Month,
b.Fact_key
};

From this query I try to group by Month

query = query.GroupBy(x => x.Month);
Grid1.DataSource = query;
Grid1.DataBind();

Then I get the following error which says:

Cannot implicitly convert IGrouping int ? into IQueryable

View 3 Replies


Similar Messages:

SQL Server :: Name From Table A ,minimum Rate1 And Rate2 Values For A Month In A Dropdownlist From Date Field From Table B?

Nov 19, 2010

I need to write a query to populate a gridview with minimum rates in ascending order for a month from three tables.For example i have three tables A,B,C as follows

TABLE A TABLE B
TABLE C
Id id id
Quote_no Quote_no Quote_ no
Name Rate1 Equip_name
Rate2 E_rate
Date R1_rate
R2_rate
Date

Now if the data is as follows

I need to get the Name from Table A ,minimum Rate1 and Rate2 values for a month in a dropdownlist from date field from Table B and the corresponding minimum rate(E_rate) for Equipment E1 and E2 only from Table C for the month in ascending order group by Name.

TABLE A

id
Quote_no
Name
1
101
XYZ

2
102
ABC
TABLE B
id
Quote_no
Rate1
Rate2
Date

1
101
105
200
12/11/2010

2
102
90
210
15/11/2010

TABLE C
id
Quote_no
Equip_name
E_rate
R1_rate
R2_Rate
Date

1
101
E1
60
0
0
12/11/2010

1
101
R1
0
110
0
12/11/2010

1
101
E2
80
0
0
12/11/2010

2
102
R2
0
0
300
15/11/2010

2
102
E2
100
0
0
15/11/2010

2
102
R1
0
60
0
15/11/2010

2
102
E1
230
0
0
15/11/2010

View 9 Replies

C# - Selecting Data From SQL Server Table According To Month?

Mar 31, 2010

I have to come up with a way to get data from a SQL server table given it's month

There's a smalldatetime type field called "date" in the "events" table and a field from it looks like this:

29/01/2003 17:00:00

It should be one among those that appear in the gridview when I select jan/03 in a given DropDownList control in ASP.NET.

What would be the best way to do this? Assuming I only want to go as long as 10 years to the past, wouldn't making a dictionary be a good way?

How do I change it so the top month is always the current, and each month another options appeaars in the dropdown ?

It should be a common issue, so that shall not be a trick, but I want a good and clean way of doing this, and (since I'm new to asp.net) I myself would come up with something messy after a long time trying.

So what I want is:

1) Select

2) Best way of populating DropDownList (with the current month always at the top)

3) Best way to bind the DropDownList user-friendly way of writing months to the select query-friendly way of writing datetimes

Info: ASP.NET, (C# or VB.NET), SQL Server 2005

View 4 Replies

SQL Server :: How To Get The Data In A Table Based On Month And Year

Jan 8, 2011

I have a requirement that I have to retrieve data base on month and year.I am using the below query

<pre lang="sql">SELECT SUM(areasft),DATEPART(year, sdate),DATEPART(month, sdate) FROM storedata
GROUP BY DATEPART(year, sdate) ,DATEPART(month, sdate)
ORDER BY DATEPART(year, sDate) ,DATEPART(month, sDate)</pre>

The above query is retrieve data like below.

SUM YEAR MONTH
51013 2000
1
30970 2007
1
NULL 2007
3
900 2007
6
807 2007
8
NULL 2007
9
1756 2007
10
7535 2007
11
NULL 2008
1
1193 2008
2
4230 2008
3
350 2008
4
2200 2008
5
4660 2008
6
6685 2008
8

But I need to display including all the months of the year along with year irrespective of SUM . My query only displays only some months in a year.

View 12 Replies

Adding A Group Object To A Table?

Feb 16, 2011

Just wondeing is there a way to add a group of single objects to a row in a db. For example

i have a Class table and i want to have a student column in the stable that can hold all the students i add to that specific class. Ie all the students in mathematics.

Is there a way to do this in sql server and then implemenmt it in vs?

View 3 Replies

SQL Server :: Group Table Records By Hour For The Last 24 Hours?

Oct 15, 2010

i have a table which records visits to a page, what i want to do is get a count of the last 24 hours and group the visits by the hour.

This is my table structure;

ID, ChannelNewsID, AddDate

This is what i did so far however it gives me both past and future records where as i want 24 hours previously starting from when the query was run. Here is what my query looks like;

[Code]....

View 7 Replies

Web Forms :: How To Import Exsisting SQL Server Table To Access Table(new Table)

Dec 10, 2010

my main intention is that, the exsisting table of sql server database(.dbo) with 1000's of records, that should be import to a new access database table(.mdb).for example if we want to had a new table in db2, of exsisting table in db1 with some conditions by using "select * into New_Tabel from (select * from Exsisting_Table where <Condition>) as objectName". Here the new table is created and records inserted in one execution in db2. The same work should be done for access(sqlserver db --> Access db).Here the new access database table with given name (as string_sysdate) must be created dynamically by clicking a button (multiples time creating new table).Is there any query or c# code for sql server database to access database.

View 2 Replies

DataSource Controls :: Change File Group Using Alter Table Query?

May 6, 2010

I have a table that contains image data type and has more than 20,000 records.I want to change its file group to the new file group. I tried to change it using table designer, but everytime I wanted to save it, it occured an error with this message:

[Code]....

Does anyone know how to change file group using Alter Table query? I'm using SQL Server 2005.

View 2 Replies

SQL Reporting :: Group Header Cell Of A Table In SSRS Graphs Alignment?

Dec 6, 2010

I have been building a report that shows several line graphs where the X axis is TIME.I have put each graph in the group header cell of a table in SSRS.I have tried many things to be able to line up the graphs (get the X axis to line up the same times vertically).I have used the align X-Axis option and it does not seem to work.

View 1 Replies

Web Forms :: Use Html To Create Table(<table></table>) In Code Behind C#?

Jan 13, 2010

how can i use html to create table(<table></table>) in code behind c#?

View 18 Replies

DataSource Controls :: Group By Month - Format Like MM YY

Feb 13, 2010

i have to Count Data Month wise and Date format would be like this Feb-10 and iam using the below query but no luck .

SELECT REPLACE(CONVERT(CHAR(9), ADate, 6), ' ', '-') As 'MonthYear', COUNT(AID) AS 'Planned' FROM Employee where Status =1 and YEAR(Adate) = '2009' GROUP BY YEAR(Adate), MONTH(Adate) ORDER BY YEAR(Adate),MONTH(Adate)

View 8 Replies

SQL Server :: How To Group Weekly Data For A Month Days

Sep 16, 2010

how to group weekly data for a month days

View 6 Replies

SQL Server :: How To Check (true/false) If Every Single Entry In Table Exists In Other Table

Oct 15, 2010

I have 2 tables:

- Salesmen with Pk.SalesmenID
- Appointments with Fk.SalesmenID and busy(bit)

How can I check if every salesmen has at least one appointment

Am I on the right way with statement below, though I got syntax problems

[Code]....

View 5 Replies

Security :: Practice To Maintain A Separate Usert Table And Add Fields To The Aspnet_Users Table?

Apr 14, 2010

If I am going to use the asp.net membership and roles, the asp.net database includes an aspnet_Users table that has the userid and email address. If I have custom fields is it best practice to maintain a separate usert table and link on user id or to add fields to the aspnet_Users table?

View 1 Replies

SQL Server :: Create A Temporary Table As Existing Table With Some Condition Checking?

Jan 18, 2011

i am trying to create a temporary table as like an existing table.

create table #tmp AS ( select Table1.* from Table1 where Table1.column name in (select Table2.column name from Table2 where conditions) )

But it is showing Error...

View 2 Replies

DataSource Controls :: Select A Record From A Table And Insert Into B Table Using Linq?

Jun 29, 2010

how can i select a record from A table and insert into B table using linq?

View 2 Replies

DataSource Controls :: Way To Retrieve Data From A Table, Modify And Insert It Into Another Table

Jun 13, 2010

Basically i deal with two tables.i have a table T1 of the following format:id company_name i need to read this data and create a table T2 as followsi wrote the following code. it worked fine for retrieving data and modification but fails to insert the modified data into the 2nd table.the error is, it does not recognise the value for @token

ArrayList dynarr=new ArrayList(); // global variable
protected void Button2_Click(object sender, EventArgs e)
{
int row = 1; int i;
string strcmd = null;
string Connection = "Data Source=....";
SqlConnection conn = new SqlConnection(Connection);
string str = "select company_name from T1 where ID=@ID";
[code]...

View 2 Replies

C# - How To Format HTML Table With Inline Styles To Look Like A Rendered Excel Table

Sep 8, 2010

I'm currently stuck settings border in a html table. (I use inline stiles for a better rendering in e-mail-clients) I have this piece of code:

[code]....

That will be rendered as this:

I want the table to be rendered like Excel would render a table with inner and outer border.

View 2 Replies

Access :: Append To Table 'a' From Table 'b' Where Lastupdate = Date() Returns No Records?

Nov 18, 2010

I have an Access 2010 DB that I have a table of RAW data in. In my scenero when table 'a' has been populated all the rows with the updatedate of Now() get moved to another table... the SQL is like this...

[Code]....

As you can see it is a very simple query but it does NOT return any rows. There are actually 404 rows with todays date in teh Append_Date column.

I am stumped as to why it does not return rows?

View 1 Replies

Forms Data Controls :: Adding Values To A Table From Another Table Via Dropdown

Jan 3, 2010

I am fairly new to ASP.Net and web programming in general and I am having issues trying to add values from a dropdown list in my gridview to another table.

Here is my scenario. I have 2 tables in my SQL Express DB. When editing the values of table2 in a gridview, I would like to show some data from table1 in a dropdown so users can select a value from table 1 and enter that value in table 2.

I have the Gridview setup to show table2 data.

I created a field template and inserted my dropdown list and linked it to my table1 data source.

When I run my web form, I can click to edit one of the fields in the gridview, and my dropdown list correctly displays the data from table 1, but when I try to update the table2 with the dropdown value, it doesn't correctly update. The row in table2 never updates.

posting the dropdown value from table 1 into the appropriate field in table2..

Again, I am new to this and have been following the tutorials etc on this site, but can't find one pertaining to this topic.

View 1 Replies

SQL Server :: Adding A Bunch Of New Records To The English Table / Repeating The Data Entry Into The Spanish Table

Oct 29, 2010

I have two tables for storing language translations - tblEN and tblES. They have the same structure which is nvcEnglish and nvcLocal - both nVarChar fields.

In nvcLocal of the Spanish table, I enter the Spanish translations of words and phrases used within my app. Problem is, when I add a bunch of new records to the English table I also have to go in and repeat the data entry into the Spanish table. I am wondering if there is a way to import the newly added records into the Spanish table using Transact SQL?The plain language query would be something like:

If the data in tblEN.nvcEnglish does not exist in tblES.nvcEnglish then insert a new row into tblES with the values from tblEN

View 5 Replies

Forms Data Controls :: Error When Inserting Into Table - Cannot Insert Explicit Value For Identity Column In Table

Aug 11, 2010

I am working on a web app for an online photo album. It is the last project in Scott Mitchell's book: "ASP.Net 2.0 in 24 hours".

I am creating a page where users can enter new photo images. The functionality for uploading an image will come later. I am working on just inserting a new row into the Pictures table with an optional category, a required title and a required description.

I am getting an error when I try to insert a new row.

Here is a screenshot of the page with a shot of the dropdown list.

The Categories are user-specific. I am getting the correct values retrieved.

[URL]

There are two pretty simple database tables involved here.

NOTE: The CategoryID and PIctureID are both autoincrement integer columns.

[URL]

The page uses a DetailsView that uses a SqlDataSource that uses the Pictures table. (The DetailsView's Default Mode property is set to "Insert". The "Enable Inserting" checkbox is also checked.)

The dropdown list uses a dropdown control that uses a SqlDataSource that uses the Categories table.

When the "Insert" button is clicked the CategoryID value associated with selected (Category) Name on the dropdown list will be used along with the Title and Description values to insert a row in to the Pictures table. (If no Category value is selected, then a null value will be used for the CategoryID. This is OK because the CategoryID column in the Pictures table allows nulls.)

My problem is that I am getting this error:

Cannot insert explicit value for identity column in table 'Pictures' when IDENTITY_INSERT is set to OFF.

(FYI: I have the full version of both Visual Studio and SQL Server.)

Here is my source code for the page:

[Code]....

View 3 Replies

Web Forms :: Dynamically Created Table / The Table Subsequently Disappears?

Mar 9, 2011

Im creating a table dynamically in my codebehind to display some statistics. The table is in a usercontrol. When the page first loads, its created and displayed correctly. If I do something that generates a postback, the table subsequently disappears, this is because its created inside a !IsPostback. How can i ensure that the table, once its been generated, stays visble on the page ? I dont want to generate it each time the page loads as it involves a lot of calculations on the database which will slow the pageload down.

View 4 Replies

Table That Has Some Columns And Rows Want This Table To Have Borders That Are Visible Inside It??

Sep 1, 2010

i have a table that has some columns and rows i want this table to have borders that are visible inside it i want every column an row to be closed in borders how can i do that?

View 1 Replies

How To Save Html Table Data To SQL Server 2008 Table Value

Jul 21, 2010

[URL]above url contain a html table.I want to save this table value on XML and also want to save this table value on database MS2008.How to save html table values on database

View 3 Replies







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