Sql - TSQL Grouping And Ordering For Dynamic Table?
Jun 7, 2010
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 have very long select query which i need to filter based on some params, i'm trying to avoid having different stored procedures or if statements inside of single stored procedure by using partly dynamic TSQL.I will avoid long select just for example sake
select a from b where c=@c or d=@d
@c and @d are filter params, only one can filter at the same time but also both filters could be disabled. 0 for each of these means param is disables so i can create nvarchar with where statement in it...
How do i integrate in here dynamic query so 'where' can be added to normal query. I cannot add all the query as big nvarchar because there is too many things in it which will require changes ( ie. when's, subqueries, joins)
There are certain tables that get called often but updated rarely. One of these tables is Departments. So to save DB trips, I think it is ok to cache this table taking into consideration that the table has very small size. However, once you cached it an issue of keeping the table data fresh occurs. So what is the best way to determine that the table is dirty and therefore requires a reload and how that code should be invoked. I look for solution that will be scalable. So updating the cache on single right after inserting will not resolve the issue. If one machine inserted the record all other on the farm should get notified to reload the cache.
I am writing code to insert values from an xml file. I check for a duplicate before inserting and delete if there is a match. Is there a more effecient way to prevent duplicates before insert a record? my code: private void LoadFData() { SqlConnection oConn = new SqlConnection(ConnectionString); SqlCommand oCommand = new SqlCommand(); oCommand.Connection = oConn; oCommand.CommandType = CommandType.Text; oConn.Open(); // Load committee master files string[] strFiles = System.IO.Directory.GetFiles("fff", "ffff.dta", System.IO.SearchOption.AllDirectories); for (int i=0; i
I have a dynamic Table which contain 8 rows and 8 Colums
Table t = new Table(); TableRow rr = new TableRow(); TableCell cc = new TableCell(); and in the each Cell CC I add a dynamic Button(Or Linkbtn) LinkButton LB1 = new LinkButton(); LB1.Text = "AM"; LB1.ID ="Link1"; cc.Controls.Add(LB1); rr.Cells.Add(cc); LB1.Click += new EventHandler(LB1_Click); t.Rows.Add(rr);
i have a table with 8 rows , 8 colums and each cell contain a LinkButton (which diffrent in IDs) I want to add Lable in the same cell of this LinkBtn(LB1) which it clicked but I cann't What shoud I write here?
I am trying to generate a dynamic table andd add rows to a ASP.Net table control on my UI. My problem is as I add a new row from MyTable, in to another table the table I am copying from, will loose one row. Here is the code:
Table myTable = new Table ();
[Code]....
am just reading one row in every loop and add that row in to another table object, why is 'myTable' loosing loosing one row in each loop?
I am dynamically creating a table that contains a textbox in each cell. The table is put in a placeholder control. Everything displays perfectly. The problem is when I go to retrieve the values entered in the cells. I have the code to generate the table in a separate method called CreateTable(). In order for my program to find a table in the placeholder when I go to save, I have to run CreateTable() in a postback event AND in the PageLoad event. If I call CreateTable() in only one of those places and I try to save, it says the placeholder is empty and, therefore, I cannot save the textbox contents. I've tried calling CreateTable() from InitLoad but that doesn't work because it needs to reference values from three static controls: 1 dropdown, 1 listbox, and 1 calendar control, which I don't believe have had their viewstate rendered yet.
Does anyone have a sample code on this? I want to call the FedEx "Rate Available Services/Rate Shopping" Service to retrieve pricing for various services.
I'm attempting to create a pure t-sql representation of the default SHA-1 password hashing in the ASP.Net Membership system. Ideally, what I would get would be this:
Note: that's bogus base-64 text there. I've got base64_encode and decode functions that round-trip correctly. Here's my attempt, which doesn't work: SELECT UserName, Password, dbo.base64_encode(HASHBYTES('SHA1', dbo.base64_decode(PasswordSalt) + 'test')) As TestPassword FROM aspnet_Users U JOIN aspnet_membership M ON U.UserID = M.UserID
I've tried a number of variations on the theme, to no avail. I need to do this in pure T-Sql; involving a console app or something like that will double the work. So if anyone can supply what precisely the syntax should be to duplicate that password from the ASP.Net membership stuff
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.
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´m looking for some advice on how to create an table showing bookings, a table containing mon-sun on the horizontal axis and times at the vertical. The admin is able to edit each days bookable times (first bookable time, last bookable time) - The slottime is constant.
What I want is let the admin click on eacha cell to remove it/add it when removed. And other features as well, like create an booking for a customer.
What would be the easiest way to achive this, at the moment I use dynamic links since I cant get asp:buttons to work and the code to create an dynamic asp:table row by row and this produces some ugly code.
So any advice on how to achive such an "schedule".
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 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.
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.
I came across the below article, I would like to know how to properly respond to the drop or stop event so that I can show the Save button only once someone changed the order. In other words, I would like the Save button hidden initially, only to make it visible once a drag and drop has occurred.