|
Yes you interpretaion was correct. That's what I tried to explain (but with lots of useless word between )
It seems that SQL Server 2005 won't create this column while 2008 will. Too bad.
However, I think we could do this with the datetime also
DECLARE @Start datetime, @Count INT
SET @Start = GETDATE()
SET @Count = 5
DECLARE @c TINYINT
SET @c = 1;
SELECT TOP(@Count)
id, title, description, Date
FROM News a
WHERE Culture = @c
AND Date < @Start
ORDER BY Date DESC
The idea is the same. Define a starting point to the current datetime, fetch page and when you want the next page, define the starting point to the last date in the previous page (from the last row).
The date column must be unique in this version so two different news must have at least 1 ms difference in date. You can try it by testing different values for the @Start variable.
|
|
|
|
|
But I guess there is a problem with this approach. That is, when we show pagination buttons at the bottom of page, how can user go to page 7 from page 1 without knowing the last date of page 6?
|
|
|
|
|
Okay, if it's possible to skip pages, then this won't work. I started to think some kind of pre-pagination, but I think that won't work either...
Hmm, are the news deleted often? Could it be acceptable that if a record is deleted, a time consuming operation is executed?
What I'm thinking is that if we would have a ordinal number on the rows (1,2,3,4...) and we know the maximum at every moment then the page 6 (with 10 news on page) would be from (maximum - (5 * 10)) to (maximum - (6 * 10)) + 1. Now if we create an unique index on the ordinal column we get the maximum very fast and the query will also be very fast. The downside is that if a record is deleted, the ordinals must be rearranged starting from the deleted position to the maximum. However this would be one simple operation (although it may take awhile).
Do you see problems in that solution?
|
|
|
|
|
Mika Wendelius wrote: Do you see problems in that solution?
I don't see any problem with it dude, it seems something to work
But the question is: Is this just MY problem with pagination, or everybody else is dealing with such problem for large number of rows. Have you ever had the same problem with paging?
You know my conclusion is that, maybe, pagination has never been meant to be used for large number of rows. If a user wants to browse news, it's very unlikely that he/she wants to go to page 3000, right? We can provide user with a filter on Date of news, and then he/she will be able to first filter them based on date, and then browse them by page.
|
|
|
|
|
Maysam Mahfouzi wrote: Is this just MY problem with pagination, or everybody else is dealing with such problem for large number of rows
I think I'm not the best person to answer that. The applications I mostly design act a little bit differently. Although they handle larege amount of rows I try to keep the result sets small and avoid paging at all. I think that there propably is several different solutions and the one I suggested may be one of those. Another approach could be that you page per date as you mentioned. One technical modification could be to use partitioning (but that requires Enterprise Edition) etc.
Maysam Mahfouzi wrote: You know my conclusion is that, maybe, pagination has never been meant to be used for large number of rows
That's my understanding too. It really doesn't make sense if you're on page 212347
Also one thing that we haven't spoken is caching. The page number change quite seldomly so you could cache the pages (or let's say first 100 pages) and use them from cache. In that case you just need to now when news are added in order to redresh the cache. That can be done using polling or better yet using SqlDependency. Still if cache is used and you go to the data beyond cache the search mechanism should be efficient.
So if you try the last suggestion and let's see what it does. Also try utilizing cache. It greatly helps you to maintain overall performance of the system.
|
|
|
|
|
I'm sorry to bother you with this long conversation but I'd like to continue it till I feel like I have no more questions
I'm thinking of a problem with last approach. That's right that it does not make sense to be on page 243546, but, think of a weblog, I can see paging for blog posts, and I want to go to last page! So, there have to be some way for me to get to last page (to see the first blog post), which may be on page 23453!
The problem with your last solution is that it will not work if we want to give paging to a result set from more than one table! right?
Mika Wendelius wrote: One technical modification could be to use partitioning (but that requires Enterprise Edition) etc.
How can partitioning help? Can you show me a starting point?
Think of a site like friendfeed, in this site I can see recent activities of a user. These activities have been probably collected from different tables in database. In this scenario, what happens if I want to see the very first activities of user? (I have to go to last page of activities)
|
|
|
|
|
Maysam Mahfouzi wrote: I'm sorry to bother you with this long conversation
You're not bothering me at all
Maysam Mahfouzi wrote: The problem with your last solution is that it will not work if we want to give paging to a result set from more than one table
That's correct since the numbers are precalculated per table.
Maysam Mahfouzi wrote: How can partitioning help
Since partitioning divides the rows into smaller sets, it improves performance and makes parallel querying easier for the dmbs. To get a quick look at partitioning, see: Partitioned Table and Index Concepts[^].
Maysam Mahfouzi wrote: These activities have been probably collected from different tables in database
This is the same problem as multiple tables in a query. I don't have any good idea immediately how to do it using SQL but again a technical tool could be using indexed views[^] (again an Enterprise Edition feature). It could be something like that you do the join for all rows and include row numbering into the result set. After that the view is indexed (this partly solves all multi table queries and ordering).
|
|
|
|
|
Dear Mika
You have not been on codeproject for a long time. Hope you are fine.
I have asked a question here[^]. Could you please take a look at it?
|
|
|
|
|
Hi
To ALL,
getting a problem when i was joined two tables and specified distinction
but the rows are repeating could anyone give me the suggestion
Thanks & Regards,
Nath.
dt_messageDate str_messge str_constituencyName
2009-01-20 00:00:00.000 Second Test Ichapuram
2009-01-20 00:00:00.000 Second Test Ichchapuram
2009-01-20 00:00:00.000 The last script Ichapuram
2009-01-20 00:00:00.000 The last script Ichchapuram
2009-01-21 00:00:00.000 Test1 Ichapuram
2009-01-21 00:00:00.000 Test1 Ichchapuram
2009-01-21 00:00:00.000 Test2 Ichapuram
2009-01-21 00:00:00.000 Test2 Ichchapuram
2009-01-23 00:00:00.000 asdf sdaaaas Ichapuram
2009-01-23 00:00:00.000 asdf sdaaaas Ichchapuram
2009-01-25 00:00:00.000 Second test Tekkali
2009-01-25 00:00:00.000 test Tekkali
2009-01-26 00:00:00.000 Godavari Anaparthy
|
|
|
|
|
Based on the data on your post the rows are not repeating since always at least one column is having a different value. Distnct removes only rows where every column has the same value.
Could you post a sample of the original data and info, what kind of result you're trying to get.
|
|
|
|
|
Hi,
I'm trying to use the bloody database wizard in vs 2008 and my Oracle database setup doesnt connect using the SID ie, I would normally get a valid connection doing username/password without postfixing it with @MySID
Now, I had some tnsnames file at:
MyOracleHomeDirectory\NETWORK\ADMIN\tnsnames.ora
which contains:
MySID =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME=MySID)
(SID=MySID)
(GLOBAL_NAME=MySID)
)
)
The point is, when using the database wizard in vs, you need to fill something in the SID box to enable the OK button!!
Please help guys
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
What database wizard do you mean? The one in Server explorer when adding a connection?
|
|
|
|
|
|
Muammar© wrote: I'm fine now
Good to hear that
And thanks for your kind words
|
|
|
|
|
Hi,
How can I insert into a table using a value and a select clause at the same time?
I have the following:
DECLARE @id INT,
@xmlHandle INT,
@Xml AS nvarchar(MAX)
EXEC sp_xml_preparedocument @xmlHandle OUTPUT, @Xml
INSERT INTO table
VALUES (@id,
(SELECT p1, p2, p3, p4 FROM OPENXML (@xmlHandle, '/root/table', 1) WITH
(
p1 INT './@p1',
p2 NVARCHAR(50) './@p2',
p3 NVARCHAR(30) './@p3',
p4 NVARCHAR(30) './@p4'
)))
EXEC sp_xml_removedocument @xmlHandle
Cheers
hmmm pie
|
|
|
|
|
The syntax is like:
INSERT INTO table (column1name, column2name, ...)
SELECT @id,
p1,
p2,
p3,
p4
FROM OPENXML (@xmlHandle, '/root/table', 1)
WITH (p1 INT './@p1',
p2 NVARCHAR(50) './@p2',
p3 NVARCHAR(30) './@p3',
p4 NVARCHAR(30) './@p4'
)))
So you don't use the values keyword at all.
|
|
|
|
|
I'm trying to write an SSIS package that will read data from 3 hidden sheets in a workbook.
The idea is that other departments can input data into 3 non-hidden sheets, that have a user friendly layout along with instructions and examples, etc.
And the 3 hidden sheets then take this data and hold it in a basic table format with a single header row.
To simplify importing we want to just read the data from these hidden sheets... but a SSIS's standard Excel connection / Excel Source can't seem to see these hidden sheets.
Is there a way to get SSIS to see these hidden sheets without making them visible in the workbook itself?
Thanks.
|
|
|
|
|
When referring to the worksheet, try using syntax (with correct path):
...\MyExcelWorkbook.xls![Some hidden worksheet]
|
|
|
|
|
Thank you, that looks like it may be halfway to working.... now I'm getting a message about the source being read-only when I try to do anything with my Excel Source object now
There is no password protection, currently on the workbook or the sheets.
|
|
|
|
|
Red_Wizard_Shot_The_Food wrote: now I'm getting a message about the source being read-only
Red_Wizard_Shot_The_Food wrote: There is no password protection, currently on the workbook or the sheets
Is the file read-only? If it is, could you remove that. Another possibility could be that it resides in a directory where you don't have write privileges or at file level, perhaps you don't write privilege to the file.
|
|
|
|
|
Hi there
I tested Microsoft report for the first time, the report viewer is pretty cool and connecting to db (using dataset) is far easier that Crystal report BUT I have bad design problem.
the first thing in report designer is the first problem, the width of page is terrible! a lot of things in designer is not easy to use and I can't tell the designer how to adjust the table of contents to fill page.
anyone has any idea what is my wrong? do you have same problems?or good sources to look?
thx in advance
|
|
|
|
|
Hi,
I've been stuck for some time trying to set up a database and access it from a program.
I don't know which database to use which is part of my problem. I've tried using sql server but I don't know how to create a connection to it from a program. For example I have a connection string but I don't know what to use as a user id or password. I had an oleDb database set up and it was working fine but I don't know how to write data to it.
Could somebody give me advice on which database to use and how to set it up?
Any help would be appreciated.
Thanks
oh by the way I'm using c#
|
|
|
|
|
I would advise you to get a few good books, but to your questions:
toprogramminguy wrote: I don't know which database to use which is part of my problem
You could use SQL Server Express Edition. Download, install it and start using by creating a db, tables etc.
toprogramminguy wrote: I've tried using sql server but I don't know how to create a connection to it from a program
You use SqlConnection[^]. Define a connection string and open the connection. Good example in the link in examples.
toprogramminguy wrote: I don't know what to use as a user id or password
If you use integrated security, you don't need separate username and password. If you use SQL Server authentication, you use SA as user and the password is defined during setup.
toprogramminguy wrote: I had an oleDb database set up and it was working fine but I don't know how to write data to it
Don't know what this means. OleDb is a way to connect to a database, not a database.
One book you could start with is: Beginning C# 2008 Databases: From Novice to Professional [^]
|
|
|
|
|
I mean an mdb database. I thought that was an ole db database. Thanks anyway
|
|
|
|
|
toprogramminguy wrote: I mean an mdb database
Okay, I see. Mdb is a SQL Server database file which can be attached to an existing SQL Server instance and then it can be used.
toprogramminguy wrote: Thanks anyway
You're welcome
|
|
|
|