Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 11th, 2007, 10:31 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by rstelma
 I'm trying to understand this myself.

Glad it's not just me then :)

If you are trying to populate dropdown boxes based on the choice in the first and maybe subsequent ones one approach is to just grab all the data at the first request and manipulate on the client. This is a good choice if the dataset is not too large and the data is basically read only. Otherwise you pass the results of dropdown combination on each choice. I can see that the latter could use an array but with only five choices it would seem easier to use a five (one fewer than the number of dropdowns) parameter stored procedure. The first time you pass the first dropdown choice and leave other parameters null, the second time you pass the first two choices and leave the rest null etc.
Perhaps you need multiple select dropdowns? Then you would have to use a pseudo-array, each parameter holding the choices of the dropdowns. If this is the case and you can't retrieve all the data at once then look at the link I posted above for some examples of handling arrays.

--

Joe (Microsoft MVP - XML)
 
Old October 11th, 2007, 06:37 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You may also want to think about the load balancing issues on your approach. You can only have one sql server. Generally its a good idea to offload the fine manipulation of data to the web server(different box) reducing the load on the SQL server, thus balancing the load more between the web server box and the sql server box. If they are the same box, it's still a good idea for when you move your web server off the SQL box or vice versa. The type of thing your trying to do is probably best handled on the web server.


 
Old October 11th, 2007, 06:52 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

That's good info, Rob, but what's that got to do with identifying the information to be passed? We're trying to figure out what msbsam is doing... it doesn't sound like he/she needs to pass an array into SQL Server at all but there's a bit of a language barrier problem... and I don't understand why msbsam thinks an array needs to be passed.

--Jeff Moden
 
Old October 11th, 2007, 07:53 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

O.o I dislike language barries, it would be wonderful if the entire world spoke one language =\ Anyway.

msbsam, I think what you are saying is that you have a GUI with a bunch of dropdowns and, as you work your way down, the item you select in X drop down affects the values displayed in the subsequent dropdownlist.

Based on this statement you made:I DONT WANT TO MAKE ARRAY INSIDE MY C# what I assume is that you are looking for an alternative way to bind a dataset to dropdown list, am I correct in thinking that?

for example I think you might be doing someting like this:

ArrayList arr = new ArrayList();
//populate data
dropdown1.datasource arr;
...

And this is causing your application to slow down, is that correct?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old October 18th, 2007, 11:32 AM
Registered User
 
Join Date: Oct 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have a similar problem I am attempting to tackle... have a slideshow database and am trying to resort the slides because the user sometimes decides to delete one right out of the middle. Here's the code I have so far. The problem is I can't seem to SORT BY the sort_order column prior to the sequence number being assinged. I tried throwing an ORDER BY in the COUNT(SELECT... ORDER BY) but then SQL kicks back an error telling me I violated it's rules).

SELECT (SELECT COUNT(PK_ID)
                       FROM slideshow_slide AS x
                       WHERE x.PK_ID <= y.PK_ID) AS sequence, PK_ID, sort_order
FROM slideshow_slide y
WHERE (slideshowID = '3')
ORDER BY sequence

What I am trying to do but SQL doesn't like is:

SELECT (SELECT COUNT(PK_ID)
                       FROM slideshow_slide AS x
                       WHERE x.PK_ID <= y.PK_ID ORDER BY sort_order) AS sequence, PK_ID, sort_order
FROM slideshow_slide y
WHERE (slideshowID = '3')
ORDER BY sequence

What is the work around other than creating and dropping tables?
 
Old October 18th, 2007, 11:42 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

The connection to arrays escapes me.
Why not just order by PK_ID? Or if you are using SQL Server 2005 then use the ROW_NUMBER function.

--

Joe (Microsoft MVP - XML)
 
Old October 18th, 2007, 12:15 PM
Registered User
 
Join Date: Oct 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can't sort by PK_ID because user deletes a row (ie slide 25 of 50) then creates a new row (identity becomes 51) but user wants the slide to be #25, so they set the sort order to 25, but you order by PK_ID then it shows up at the end of the list. Don't have SQL 2005, that's why the post is here in the SQL 2000 area.

 
Old October 18th, 2007, 01:55 PM
Registered User
 
Join Date: Oct 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

SQL 2000 and PK_ID is the identity and increments by each time a new record is added, so if you delete a record (ie 25) and then add a new one, the new one would be 51, so sorting by PK_ID doesn't fly.
 
Old October 18th, 2007, 02:07 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

In that case I can't see how the count of rows with a lower id will help. When a user deletes a row and adds a new one what gets put in the sortorder field?
Can you show an example of a before and after table with a few rows?

--

Joe (Microsoft MVP - XML)
 
Old October 18th, 2007, 02:45 PM
Registered User
 
Join Date: Oct 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, when a user is deleting an entry, there is a gap in the sort_order, ie record 25 is missing. So the point of the sequence column is to resort the data with numbers that start at 1 and increment by 1 without any gaps, like an ASP array but without relying on ASP because it's so slow and a resource hog. The sequence number generated becomes the page number so they need to be in order, without gaps.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Response.Write an Array (OK in Access but Not in M musosmiffy Classic ASP Databases 0 July 15th, 2007 04:06 PM
Difference between Trace.write and Debug.write surendraparashar ASP.NET 2.0 Professional 1 June 27th, 2007 02:12 AM
SQLserver 2000 vs SQLserver 2005 Express cJeffreywang BOOK: Beginning ASP.NET 2.0 and Databases 0 April 22nd, 2007 09:52 AM
is there anything like array in sqlserver? starnet SQL Server 2000 5 July 19th, 2006 08:01 AM
How to write xml data in SqlServer rekha_jsr XML 1 October 21st, 2004 12:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.