C# - Get Updated Query Results On Page?

Aug 2, 2010

I have an asp.net intranet site hosted on IIS on my computer.

On one page you can enter two user id's and get a side by side comparison of their roles in our (custom app) system.

I often use it to add roles when I'm setting up new users. After running the query, if i change a role and run the query again it will not show updated results. It's being cached somehow. I have to go to another page and come back and them run the query to get updated results.

How can avoid having to navigate away to get the updated query results displayed.n

[Code].....

View 2 Replies


Similar Messages:

C# - The Query Results Enumerated More Than Once?

Mar 17, 2011

datacontextclass dc=new datacontextclass ();
var news= dc.GetNewsCompany(Int64.Parse ( _idCompany));
if (news.GetEnumerator().MoveNext())
{
foreach (var item in news)
{
drpListNews.Items.Add(item.Title);
}
}

return error:{"The query results cannot be enumerated more than once."}

how can check result != null in LINQ;

View 3 Replies

C# - Why Is SQL Query Returning Duplicate Results

Dec 1, 2010

The SQL is below - each result is coming up 3 times rather than just once.

SELECT Consignments.LegacyID, TripDate, CollectionName, DeliveryName, Pallets, Weight, BaseRate, Consignments.FuelSurcharge, AdditionalCharges, BaseRate * Quantity AS 'InvoiceValue', Consignments.Customer, InvoiceNumber,
CASE
WHEN child.LegacyID = Consignments.Customer THEN child.LegacyID
WHEN parent.LegacyID = Consignments.Customer THEN parent.LegacyID
ELSE this.LegacyID
END AS 'InvoiceAcc'
FROM SageAccount this
LEFT JOIN SageAccount parent on parent.LegacyID = this.InvoiceAccount
LEFT JOIN SageAccount child on this.LegacyID = child.InvoiceAccount
JOIN Consignments on (Consignments.Customer = this.LegacyID AND this.Customer = 'True')
OR (Consignments.Customer = parent.LegacyID AND parent.Customer = 'True')
OR (Consignments.Customer = child.LegacyID AND child.Customer = 'True')
WHERE (this.LegacyID = @Customer) AND (TripDate BETWEEN @fromdate AND @todate) AND (InvoiceNumber IS NOT NULL)

The SQL was given to me for another similar query, but this time I have modified it to try to use it for the query I'm doing now, so I'm assuming that I'm doing something stupid.

View 2 Replies

LINQ-to-SQL Query Returning No Results?

Mar 5, 2011

I have a query using LINQ-to-SQL. It queries an underlying database table Rooms. It uses Where conditions to narrow down the results, namely:

Gender.
Current Occupancy < Max Occupancy
Available Flag is Checked

I know this should return results but it keeps returning an empty set. Any ideas? Code is below

Dim selectedHalls = (From sh In dbHalls.Rooms _
Where sh.gender = Session("gender").ToString _
Where sh.max_occupancy > sh.current_occupancy _
Where sh.is_available = 1 _
Select sh.building_name).Distinct()

UPDATE: I've verified that the issue is with the statement where sh.is_available = 1, which doesn't make sense since this is a bit field.

View 3 Replies

Access :: Using Results From A Sql Query In A Variable?

Oct 2, 2010

I've managed to use my MS Access database with repeaters and gridviews in my website. Basically, printing the result of a query directly to the website seems easy enough using something like this :

[Code]....

After quite a bit of googling this seems to be a common way to do this. My question then seems kinda silly.

I want to use some of the data from the query in for example a variable without sending the data to a repeater or gridview and so on. Say I just want the username and a password from a database and want to store the username in one variable and the password in another for further use in the code. What do I do?

View 1 Replies

ADO.NET :: How To Alphabetise The Results From A Linq To Sql Query

Jan 26, 2011

I can't seem to change the order of the results coming back from a linq to sql query, I want just to return the distinct values from the field x.manufacturer in alphabetical order, this is what I have and it isn't working:

public IQueryable<string> Dropone()
{
return (from x in CAT.CatalogueDatas
where x.Parent == null
orderby x.Manufacturer
select x.Manufacturer).Distinct();
}

Currently I get the distinct values in non-alphabetical order, in fact I'm not sure what order they're coming out in, don't think it's the order in which they appear though.

View 5 Replies

Output Query Results In HTML?

Mar 11, 2011

i query a database for retreiving all the columns. I will probably have many rows. Im trying to output the query results into an html table. This is what i have so far:

[code]....

How could i store the many rows and output them using html as soon as i open a page?

View 3 Replies

ADO.NET :: How To Get Results Of Query (single Value) Into A Variable

Jan 16, 2011

I have a Query which I run as an SQL. This is my SQL:

"SELECT COUNT(*) As NoDup FROM [XXX Dir] WHERE (FileName Like 'XXX_YYY_20100916.txt')"

The "XXX Dir" is a table and "FileName" is a text field within that table.

When I execute the SQL in the Query development windows, it returns a single value like 2.

I would like to assign that value to a variable so I can use it in my VB code.

View 1 Replies

Web Forms :: How To Display Sql Query Results Dynamically

Jan 26, 2010

I want to display sql query results in my web application (asp.net webpage) dynamically at the run time. But I don't know how to do that. Is there any control to do that? Or is there any code? Could you give some examples?

View 4 Replies

Avoid Error When No Results From Entity Query

Mar 14, 2011

I have a simple Entity query:

[code]....

I then check whether one of the result values is more recent than six months ago using an if..then like so:

If rhcexists.First.SignatureDate > Date.Today.AddMonths(-6) Then
End If

However, if there are no results returned this will return an error. Is there a way for me to tell it to act as if the date is older than six months if there is no value at all? e.g., could I in pseudo do something like:

If Exists(rhcexists.First.SignatureDate, Date.Today.AddMonths(-8)) > Date.Today.AddMonths(-6) Then
End If

View 2 Replies

Concatenating Results From SQL Query And NULL Columns?

May 11, 2010

I need to concatenate several columns of a table into a single value, then show that value in an asp dropdownlist. The SQL code I'm issuing is as follows:

SELECT UserID, CustomerNum, UserName + ' - ' + UserAddress + ',' + UserCity + ' ' + UserState AS UserInfo
FROM Users
WHERE (CustomerNum = @CustomerNum)
ORDER BY UserName

I then set 'UserInfo' as the text field in the dropdownlist.This generally works, except occasionally one of the columns in the database is null (for example, UserState). When that happens, the entire concatenation is null, and I get an empty entry in the dropdownlist.

Is there something in SQLServer that will allow me to ignore those NULL results, or will I have to code something up in the DataBind event?

View 6 Replies

Query - Use A Checkbox To Change The Results Of A SqlDataSource?

Feb 2, 2011

I'm using Visual Web Developer 2010 Express. This is my first attempt at creating a .NET page. I have a Gridview on a page that displays the results of a GridQuery. This works. I have a checkbox control(cb_Filter) on the same page that if checked, should add to the where clause of the GridQuery, (where Column5 IS NULL). How do I check the state of the check box so it will run the query with or without the "filter".

View 2 Replies

C# - Use XMLHttpRequest To Execute A SQL Query And Return The Results?

Feb 9, 2011

I'm building a web app for my company that will run a query every few seconds against SQL Server, and the data that it returns is which database is restoring and how much % complete it is. I have the query already set up and it works fine.

What I want to do is on my Web Form, have a "div" element that will contain the % complete of a database restore, and have it update every few seconds using the JavaScript timer object:

setInterval(function, interval)

I figure I would need to use XMLHttpRequest to send the request to the web server which will run the SQL query. Am I on the right track? How would I even start to do this?

My SQL query is below:

Use master
Select der.session_id, der.command, der.status, der.percent_complete, *
From sys.dm_exec_requests as der
Where percent_complete > 0

View 1 Replies

SQL Server :: Insert Query Results Into Table?

Feb 19, 2011

[Code]....

i want to insert the result of that query into nother table in my database. please help me find a way to do that.

View 2 Replies

.net - Get Number Of Matched Results Of A Query To SharePoint?

Aug 1, 2010

I am using VSTS 2008 + C# + .Net 3.5 + ASP.Net + SharePoint Server Enterprise 2007 on IIS 7.0 with Windows Server 2008 Enterprise.

I am currently using queryex web serivces API to get matched query results for a specific query. My question is, how to get the number of matched query results without returning the whole query results? I only need the number of matched query results.

[URL]

View 1 Replies

Web Forms :: Display Results From Search Query?

Jun 8, 2010

I am developing a web form for search capability. The search query should return records from three different tables. How to display these three table records in three different rows. The search query should get the results from Table 1 and Table 2. Table 2 and Table 3 has a parent child relation ship. Which controls can I use for this purpose?

View 5 Replies

DataSource Controls :: Validate Results Of A Query?

Jun 17, 2010

I am trying to find out if there are records in a table

based on the results of the query.

I have this that is not working

The query works but the problem is validating the resutls

MembershipUser myUser = Membership.GetUser();
Guid userIdPosts = (Guid)myUser.ProviderUserKey;
int currentThreadid = Convert.ToInt32(Request.QueryString["Threadid"]);
var query = from t in context.TrackLists
where t.UserId == userIdPosts && t.ThreadID == currentThreadid
select new { t.UserId, t.ThreadID };
foreach (var results in query)
{
Guid queryUserID = results.UserId;
}
if (queryUserID == null)
{
}

View 2 Replies

How To Assign A Value To Label Based On Results From SQL Query

Apr 5, 2016

I have an entry page that contains a datalist. I also have an ascx user control page that when it runs on page load, renders an html table template which contains category information from an SQL self referencing table. When the SQL query run on page load, it bind the results to a datalist called dlCategory, and repeats for all rows that have no value in a field in this SQL table called ParentCategoryCode. The SQL table is called ServiceRequestCategories and basically consists of CategoryCode, CategoryTitle, and CategoryDescription, and may or may not have a ParentCategoryCode associated with it.

Records without a ParentCategoryCode are top level categories, and anything that has a ParentCategoryCode are second or third level categories. The way I have the data set up, it ends up being 4 rows that are returned and rendered as 4 html tables. Each one of these is tied to the user control, and each user control runs another datalist, and shows all CategoryTitle values for each Category that has a ParentCategoryCode (second level categories). This works when you click on a LinkButton for any CategoryTitle. This all works fine.

My question is, how can I use an SQL select query to plug the value of the CategoryTitle into a label called lblCategoryBreadCrumb on my main entry page? Here is my code, but it does not seem to work.

Protected Sub ShowBreadcrumbLabel()
Dim strSQL As String
Dim dsData As DataSet
Dim dtData As DataTable

[Code] .....

View 7 Replies

SQL Reporting :: Query Designer Returning Different Results To SSMS?

Jan 29, 2010

I'm having an issue with SSRS 2008 inside VS 2008, where I have a report that is connected to the database via a Data Source which is working correctly, but when I execute a query inside the query designer to test my data, it returns zero records.

The issue I'm having is that the EXACT same query inside SSMS returns the correct record. I'm really stumped as to why it all is connected, but not returning the record. I have another report in the solution that uses the same database, but that one actually works ok.

View 5 Replies

Forms Data Controls :: SQL Query Results Placed In Email?

Jul 29, 2010

(Mods, move if I put this in the wrong place) I'm running queries against SQL databases, and I'd like for the results of my searches to appear in table form in an email that is then sent out dynamically. I currently have the results appearing in a Datagrid on a webpage which I'm then manually transferring to an email form to send. I'd like to streamline the process so I don't need to do any manual entry.

How can I have a table/datagrid/whatever in an email that gets populated with the results of a SQL query?

View 1 Replies

DataSource Controls :: Random Results From A LINQ To SQL Query?

Jan 23, 2010

I have this LINQ query:

var agnts = (from a in db.agents select new { a.userid, a.name }).Take(10);

How can I get randomly get 10 records from my agents table?

I have tried:

agnts = agnts.OrderBy(n => Guid.NewGuid());

but this doesn't seem to do anything.

View 5 Replies

SQL Server :: Posting Results Of Query To Session Variable

Mar 22, 2011

I am having trouble getting a SQL query to post its results to a Session variable. I am close, but no success thus far. Here is what I have:
[Code]....

However, I keep getting this error when I click to a new page that is using this "PracticeID" Session variable: No mapping exists from object type System.Data.SqlClient.SqlCommand to a known managed provider native type.

View 5 Replies

SQL Server :: Can't Save Query Results To Excel File?

Feb 3, 2011

I am executing the following T-SQL code, which runs successfuly according to message I see at end of its execution, but the file c:cptest.txt is never created. I have checked for this file and it doesn't exist. what is the issue here?

EXEC MASTER..xp_cmdshell 'bcp "SELECT top(10) from Person.Address" queryout "C:cptest.txt" -T -c -t,'

View 8 Replies

Entity Query - Combine Into One And Avoid Merging The Results

Nov 6, 2010

I can't seem to figure out how to write this query properly. I've tried various combinations but nothing's worked yet. Below is the relevant portion of my database model: I need to select the products that match a given Category and Group, and that match a given Year, Make, Model, submodel. This I've done below:

ItemList = From P In gDataContext.Products.Include("Groups").Include("Groups.Category1").Include("LookupYearMakeModels") From G In P.Groups Where G.Category = Cat And G.Grp = Group From Y In P.LookupYearMakeModels Where Y.Year = YMM.Year And Y.Make = YMM.Make And Y.Model = YMM.Model And Y.Submodel = YMM.Submodel Select P

I now also have to select products that match the Category, and Group but are Universal (Product.Univeral = True). I'm currently writing two queries, the one above and the one below. I'm merging the results of the two by simply using ItemList.AddRange(ItemList2) ItemList2 = From P In gDataContext.Products.Include("Groups").Include("Groups.Category1") where P.Universal From G In P.Groups Where G.Category = Cat And G.Grp = Group Select P But I want to combine both queries into one and avoid merging the results. How can I do it?

View 2 Replies

Sql - Dynamically Generating Buttons Based On Query Results

Dec 20, 2010

I am trying to add some filters to a gridview that I am working on, and I'm wondering if it is possible to generate links or buttons above the gridview based on the years returned in the dataset. For example, if my dataset contains dates from 2001, 2009, and 2031 in my date column, I would like to be able to take that data from my SQL query (getting a distinct list of years is not an issue), and generate the buttons. From there, I would filter the data in the gridview based on the user clicking the buttons.

Is dynamic generation of buttons possible in ASP.NET? I do have some other ideas of how to accomplish the same functionality, but I would prefer to do it this way.

View 1 Replies







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