I have a dataset generated from xml from a web service.Data needs to be sorted by date order descending, I cannot get the web service changed so thought I'd try:
Code:
repeater1.DataSource = dsCombinedBlock.Tables(2).Select("Status < 3 and status <> 99", "DateReceived desc")
However the dates are treated as a string so the results look like
I am a bit confused how to say this but here goes.I have a sql server 2008 database tablewhere I want to select rows by descending order of a [column name] and then select first 10 rows from that output.I was trying something like select top 5 * from (select * from movie_data order by hits DESC);this does not work and I'm quite new to query-writing.
Dim dt As New DataTable Dim da As New SqlDataAdapter(s, c)
c.Open() if Not IsNothing(da) Then da.Fill(dt)
[code]...
When I call da.fill I am inserting all records from my query. I was then hoping to filter them to display only those where the GroupingID is equal to 0. When I run the above code. I am presented with all the data, the filter did not work. Please can you tell me how to get this working correctly.
I have records in the datatable which I have retreived from xml file.
Dim docDataSet As New DataSet Dim docReader As New XmlDocument Dim xnl As XmlNodeList docReader.Load("UserProfile.xml") xnl = docReader.SelectNodes("/Users/user") For Each xn As XmlNode In xnl Dim xr As New XmlNodeReader(xn) docDataSet.ReadXml(xr) Next xn Dim Dm_table As DataTable = ds.tables(0)
Now what I want to do is execute a select query like below:
Select * from user where userid in (select ID from Dm_table)
Retreive the records from the User table based on the ID's in the datatable.
How to select top n rows from a datatable/dataview in asp.net.currently I am using the following code by passing the table and number of rows to get the records but is there a better way.
public DataTable SelectTopDataRow(DataTable dt, int count)
{ DataTable dtn = dt.Clone(); for (int i = 0; i < count; i++) { dtn.ImportRow(dt.Rows[i]); } return dtn; }
I am trying to search how to select rows from a datatable. When selecting these rows I should be able to delete the row or edit (update) the row.
I am using the following code to load the data from MsSql 2008 to a dataGridView;
DataTable dtTypes = new DataTable(); SqlConnection con = new SqlConnection(Settings.Default.JLTrackConnectionString); SqlCommand cmd = new SqlCommand("SelectJobTrackForDate", con); [code]....
Is there any good article which tackles this because I am searching for the bad keywords I think.
I have an already created DataTable object which i am using for my girdview (asp.net) i also need to bind a column of that object to a DropDownList. The datatable has the correct details in the column but the column contains more that 1 of the same name in the column - hence I would love to just do some kind of SELECT DISTINCT on the datatable and copy it to a new datatable for use with binding the dropdown.
This would allow me to save resources by making another trip to the database.
Here is an example, the current datatable has a column called items and in this column has the following entries
1 1 1 1 5 5 6
And of course i need only unique items for binding to my dropdown, hence i need the following data
1 5 6
Of course i don't want to change the original datatable object but rather make a copy of it will the new details.
The values are number but varchar, for example '100', '73', '87'. When i see the data this return 100, 87, 73, when should by 73, 87, 100 how can i sort the data????
I have an application which was recently ported from Classic ASP to .NET 3.5. I'm pulling some data from a stored procedure and once retrieved, I'm doing using the Select method on the DataTable in a loop so I don't have to keep going back to the database.It appears that there's something wrong here as I can refresh the page repeatedly and see the memory usage increase by a few megabytes, up to the point where we get an error. If we recycle the app pool in IIS, it starts working again, for a little while.
Is there a memory leak in this method? I did some research on the subject and Microsoft said there was an issue like that in .NET 1.0 and 1.1, but I'm using a higher version.Or, is this something else, such as not managing resources correctly? Here's a snipped of my code:
[Code]....
Initially, this app was using XML instead of a datatable and using XPATH to query the data, but it was too slow. I thought using a dataset with DataTable selects was a better option, but now we found this issue. I was thinking since the loop executes several hundred times that getting all the data and filtering through it on the client was a better choice instead of calling several web methods to get the subsets of data.
have created a data table as global data table for the session. So when the user selects the drop down Address Type Main , Street, Emergency - I want the Address text fields to display based on user selects. So, for my dropdown i have datavaluefield column as addressid. And the datasource for this is datatable. I was having problems converting from datatable to dataview. Does anyone know how to do this? I was geting errors cant convert from datatable to dataview. I was choosing dataview because you have the filter option. But then I saw you could also select in data table. So I am trying to select a row in datatable with select with expression like this:
Dim dtAddress As New DataTable dtAddress = GlobalVariables.AddressTable
i could bind the data form tables to dropdownlist in asp .net using linq.
ex: var res=from n in dc. contacts where n.location==Hyd select new{n.Id,n.Name}; var res1=from n in dc. Morecontacts where n.location==Hyd select new{n.Id,n.Name}; dropdown1.Datasouce=res; dropdown1.DataTextField="Name"; dropdown1.DataValueField="Id";
I have a ListView with Checkbox. My requirement is - When I click on any checkbox then it should return all the columns values of that row on behalf of that CheckBox. After much study I came to know that using DataTable and DataRow I can get all data of particular ID of a Row. But I am unable to work with this. My code is something like below:
now in above, if i want only those hotelid where amenityid is 7585 and amenityid is 65474 and not any else hotelid , then how to use select query in datatable in asp.net
the best way to do the following (I'm using a simplified example of my actual problem?Say I have a customer ordered items table with fields: oItemId, OrderId, ProductId, ItemPriceI want to query where OrderId >oMin && OrderId <oMaxand for each value of OrderId I want to find the record with the highest ItemPriceso for a single OrderId the query would be:(from o in context.orderItems where OrderId==x orderby o.ItemPrice select o).first()but OrderId isn't a single value. If I modify the where clause then this query would still produce a single record whereas I want a single record per OrderId.oh and as an additional question: does anyone have a compact test for whether a record exists. I am using the querystring to specify an Id and there are numerous things that I want to protect against. If I do:
var myRecord = from o in context.orders where o.orderId == request.querystring["Order"] select othen this fails if the querystring isn't specified. So first I test that the querystring != nul . Then I need to do:bool recordExists = (myRecord != null)because even if the querystring is specified it may be an invalid orderId and thus the query returns no results. Is there a shorter/simpler way to calculate the result. I have not yet got to grips with lambda expressions and I'm not sure whether there is a better approach with lambda expressions.
This was programmer error - a problem with my SQL. I am populating a slideshow extender control successfully from a list of images maintain din a MySQL database. I have created a "back" button that executes the following javascript: [Code]....
This correctly goes back to my web service method that fetches rows from my database. I issue an "order by" in the SQL to sort the rows returned in descending tiome order and have verified that they populate the slide array in that order. However, when the page renders, the slideshow appears to play them in almost a random order. Is there any trick to getting images in a slideshow array to play in a particular order?
I hoping someone may be able to point me in the right direction for this. Basically Im writing an asp.net web control to dynamically display a set of data based on field data stored in the database.
I want the control to create a dynamic asp table from a set of data from the database, however I cant get my head round the query needed to order the data into a list that I can create a htmltable from (if that makes sense)
my data looks like this, where I have a field name, the order the corresponding control will be rended in, and the number of columns that control takes up in the asp table:
I have made a couple of attempts at creating a stored procedure that accepts an integer representing the number of columns the table will have, with no real progress. I would like the query to return something like the following (if the input parameter was 2 (columns)) - where the fields are grouped into logical rows
I get this run time error "no supported translation to SQL".
What i want is to get lists of the posts, and do a small quick calculations of the rating and then sort those from highest to low and take 5 posts only.