Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 February 17th, 2005, 10:53 AM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default hlchuah77

Hi, does anyone know how to perform paging and sorting datagrid where the sql query involve more than one table? For example, when using equijoin. I am having no problem if there is one and only database table. Any suggestion?

Thanks.

 
Old February 17th, 2005, 03:05 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Not sure what you mean. If you combine your results into one table through SQL, stored procedure and use a dataset, is not a problem. Maybe you can share your code and describe wht you mean.

jim
 
Old February 17th, 2005, 05:51 PM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default

Sorry, I am not good enough in expressing what I think. Now, I will try to express using example.

Consider the following query:

SELECT * FROM myDBTable1;

The above query is quite straight forward where it involves only one database table. When I bind the data (all column from myTable1) to DataGrid, and I set AllowSorting="true" and AllowPaging="true". With few lines of statement, both sorting and paging is working when I click on the DataGrid.

Now, the problem which I face. Looking at the query below again:

SELECT myDBTable1.*
FROM myDBTable1, myDBTable2
WHERE myDBTable1.ID = myDBTable2.ID
and
myDBTable1.Age = 24;

So, it is very obvious that the query above is involving two tables with a 'JOIN'. Once the data is fecthed from database and bind it to DataGrid, I will have problem in paging and sorting. It means that whenever I click on the column name on DataGrid with an attempt to sort the page, I will get some sort of error such like "ambiguous column" something like that. It is the same also if I click on the page number, error "index must >= 0" or something else.

I am looking for many solution, but still can't solve the problem. If you have "Beginning ASP.NET 1.1 with Visual C#.NET 2003", please look at page 258-261. I am following the example from there, with one different, where the book mentions only how to sort and paging DataGrid with a query which involves a single DB.

For sure I will share my coding, please let me know if you really want to look at it, I don't want to post it now because I am talking too much already. :)

Thanks for reply.

 
Old February 24th, 2005, 10:31 AM
Authorized User
 
Join Date: Jun 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi hichuah77
I am not one of the Junior or senior members of the Wrox forum nor an SQL guru but I thought I must comment on your Topic.
Your SQL Statement is not quite correct? In the SELECT statement you select all fields from myBDTable1 but nothing from myBDTable2 then in the WHERE statement you compare the ID fields from both tables but it doesn't have a select for myBDTable2.ID so the total SQL statement is invalid!??
Can this be the source of the problem?
Best regards,

Edward Stephen

 
Old February 24th, 2005, 12:51 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

The SQL is correct, however I suggest re-writing it using the new ANSI standard:

Select myDBTable1.*
From myDBTable1
INNER JOIN myDBTable2 ON myDBTable1.ID = myDBTable2.ID
Where
myDBTable1.age = 24


However I do not feel the SQL is the problem. Are you getting data back, if so, how many rows. I feel this may be a data issue.
 
Old February 26th, 2005, 11:44 AM
Authorized User
 
Join Date: Jun 2004
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to hlchuah77
Default

Thanks for the reply.

Ya, i don't think sql query is the problem. In fact, I am still try to figure out why this happen. Maybe my coding skill is not that good yet. So, I will try some other way else to see what is going wrong.










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