DataSource Controls :: Sql Query To Show All Combination Of Records?
Jan 18, 2010I've the following tables and I want the query to show all possible combination of records with SegmentID, RateCodeID & MealPlanID.
View 2 RepliesI've the following tables and I want the query to show all possible combination of records with SegmentID, RateCodeID & MealPlanID.
View 2 RepliesI have table in database with xml field and data like below
[Code]....
there are no records found
I'm trying to query records from a db using a date. But somehow the db doesn't return records.
The datetime collums have the data stored in this format in the db as datetime :
12-Apr-10 12:45:12 AM
The string a have available is in this format : 12-Apr-10
I need to somehow strip the time part of so i can use my date string in the query.
When i use the below method the database converts the datetime to a rounded date (12-Apr-10 12:00:00 AM).
But when i query for that date i still get no results.
I tried this:
SELECT ID, PerformedBy, SystemId, ServerId, CAST(FLOOR(CAST(CreateDateTime AS FLOAT)) AS DATETIME) AS Expr1, Reason, Action, Summary, EnteredBy,
Collumn1, Collumn2
FROM Changes
WHERE ('Expr1 = '12-Apr-10 12:00:00 AM')
But this way the Expr1 collumn is not recognized.
How come my query returns 0 records?
SELECT WebSiteID, BanDate
FROM tblWebSite
WHERE (BanDate <> NULL)
The BanDate is a date column. There are date times through the table in this column. I just want the ones with a date and ignore the rest.
I am using dataset which contains some records I want to query with dataset to get every time next 20 records. I don't want to do it throught loop is there any way that I can get next 20 records everytime.
View 5 Repliesi have a table for customer forecast with following fields.. customer, year, week, quantity. now i need to write the SP to retrive the records based on the from week,year and to week,year... like this... from 45th week of 2009 to 25th week of 2010. how can write the query...
View 4 RepliesI am doing update query to edit my records and save to my database...I am getting the query expression exception...syntax error (missing operator) in query expression 'WebLogin=krish'.
string strUserName = Request.QueryString["UserName"].ToString();
DateTime dateTimeNow = DateTime.Now;
string ConnString = ConfigurationManager.ConnectionStrings["Data"].ConnectionString;[code]....
I am getting the exception syntax error (missing operator) in query expression 'WebLogin=krish'.
I have a basic CMS which I'm adding to a site to display some downloads organised into groups. I have two tables, one for the groups and one for the downloads. I'm using a repeated to display the groups with another repeater inside to display the children. This works perfectly.
However some of my download groups may not have any downloads related to them and I'd like to handle this by filter the groups so that only those with a relate download record(s) are shown.
I'm trying to do this with the query which populates the top repeater based on some ideas I read but I must be going wrong with the syntax.
Here is what I'm using to try and only select downloads groups which have downloads linked to them by the download group ID.
[Code]....
Can anyone offer any thoughts on how I should construct the query to perform this?
I know I'm missing something here but I can't figure out what it is. I've got a query joining three tables....accounts, payments, and a table linking the two (there is a M:M relationship).I'm trying to pull a list of all accounts in the account table that have a payment that needs to be resequenced, and also the maximum payment priority if there are any payments that haven't been fully paid. If all payments HAVE been fully paid, I want to return a 0.
It's that last bit of logic that I can't get right. If I include that in the where clause, I get only the accounts that have a payment that hasn't been fully paid. If I take it out, I get all the accounts I get, but I get the highest payment priority whether or not the payment has been fully met.
Here is the query....how do I include the where clause criteria but still include all accounts?
select distinct
bat.acct_id,
isnull(max(isnull(crt.pymt_priority, 0)), 0)[code].....
i have a question regarding grid view. i have done almost all work i needed. but one thing i want to do is i have set 4 of page size of grid. so when i show records on the web page i want to set a iframe after first two records then iframe and then two more records like i have shown in the example image. i have used LINQ with C#.how to do it. if you people want i can show you my code.
View 3 RepliesI have a SQL Data Source that displays records after going through the Query Builder and select "Test Query" yet when I save it, go back to the design mode and select View in Browser I get nothing but a blank screen.
View 3 Replies1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like
SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.
Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).
2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query
(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).
If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.
[code]...
This query works perfectly on the query analyser.
But when configuring the Table adapter ,I try executing the query and i get 0 rows affected.
What could I be getting wrong in this case.
NB:Existing GalleryID has been supplied.
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 RepliesI am facing a big problem with simple linq query.. I am using EF 4.0..
I am trying to take all the records from a table using a linq query:
var result = context.tablename.select(x=>x);
This results in less rows than the normal sql query which is select * from tablename;
This table has more than 5 tables as child objects (foreign key relations: one to one and one to many etc)..
This result variable after executing that linq statement returns records with all child object values without doing a include statement.. I don't know is it a default behavior of EF 4.0 . I tried this statement in linqpad also..but there is no use... But interesting thing is if I do a join on the same table with another one table is working same is sql inner join and count is same..but I don't know why is it acting differently with that table only.. Is it doing inner joins with all child tables before returning the all records of that parent table?
select Groupid,GroupName,onorusername from palgroup where groupid in (select distinct Groupid
View 5 RepliesI've got a query such as
Dim MediaQuery =
From m
In dB.DOWNLOADS _Where m.ID = id _Select
which returns a record from the database. One of the fields in the record is a FK to another table. I need to read this value to be able to set a dropdown based on the ID but I can't work out how to access it. For a standard record I can just do the following txtTitle.Text = MediaQuery.FirstOrDefault().TITLE
However with the foreign key it doesn't work like that. I've tried drpGroup.SelectedIndex = MediaQuery.FirstOrDefault().DOWNLOAD_GROUPS.ID where DOWNLOAD_GROUPS is the FK field but it returns Object reference not set to an instance of an object. If you're simply wanting to read some values from a single db record in the entitiy framework and one is a foreign key how should I go about getting the value?
How do I cound the records found by an SQL query? I have searched google and have only found ways to do so in vb.net. I need to know how to accomplish this in C#.
Below is what I have made so far...
Default2.aspx file...
[Code]....
Default2.aspx.cs File...
[Code]....
i m try to read a xml file using Datalist its working , but i need to show only top 4 records how i can do that
View 3 RepliesThis is more of an SQL issue (I think) rather than .net, but I still think it's relevant area.
I have two dropdowns; first one called categoryID which has a series of numbers, the second called userID - again with a series of numbers.
If I select from the dropdowns: categoryID 4 and UserID 5 I end with the correct search result, however I need an option to show all records.
E.g. Select all from the category dropdown combined with UserID 5 that would display all records from UserID 5 (or vice versa).
Note - I am using MS Access and the numbers are classed as integers not text.
I have a series of areaID numbers in a dropdown.
I need an option where a user can select All areas and all are selected from the database.
How can I do this using SQl?
i use this query as my sql query :
SELECT TOP 5 * FROM MyTableName WHERE ID=@ID ORDER BY NEWID()
As you may know it gets 5 records by random. I use it with dataset and bind the listview to this dataset and in ItemDataBound i want to do some programming (like making some controls visible or invisible) i need itemindex.
but the question is : how can i get the itemindex of a listview when sql query selects records randomly?
How can I get gridview and detailsview to show up when there are no records. I need this for my edit's
View 4 RepliesHow can i make a gridview always started ascending, depending on one of my columns? considering that is Populate it from database SqlDataSource
View 1 RepliesAs we use datalist it will shown all the data which is on my data base. But I want to show only 5 row and rest of my data will be show on the button click so how can i do it...
View 1 Replies