DRW within a DRW (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


Lydecker -> DRW within a DRW (9/4/2002 20:08:10)

What if I need to place a DRW within a DRW??




no_mac_jack -> RE: DRW within a DRW (9/4/2002 20:33:06)

I think we went over this recently, but I don' t remember where.

Anyway, it can' t be done because you will need to be using the same variables (in the FP includes) for both DRW regions which obviously causes a conflict.

Depending on your situation, though, there' s probably a way around it. Remember that a DRW region can be used to store information for use later in the page without displaying the data immediately. Maybe if you explain the situation we can come up with a way around it.

~no_mac_jack




Lydecker -> RE: DRW within a DRW (9/4/2002 20:39:13)

Okay on my site I have to databases - one that houses articles, and one that houses comments about the articles.

The articles are displayed in a DWR on a page. I would also like to say how many comments for the article which is displayed on screen.

The articles are displayed in LISTS of 20 per page and in each returned record I wish display the number of comments.


THanks




hhammash -> RE: DRW within a DRW (9/5/2002 0:09:12)

Hi Lydecker,

Do you mean by two databases, two tables?

If yes you can create a Join query instead of creating two DRW.

Do both tables have a PK and FK?


Regards
Hisham




hhammash -> RE: DRW within a DRW (9/5/2002 0:24:58)

Hi Lydecker,

If you have two tables related by one field you can type the following sql in the custom query.

SELECT articles.ArticleID, articles.Title, articles.Author, Count(comments.Comments) AS CountOfComments
FROM articles INNER JOIN comments ON articles.ArticleID=comments.ArticleID
GROUP BY articles.ArticleID, articles.Title, articles.Author;


OR


Create a join query in Access itself, save it, import the database to your web, insert a DRW and make the record source to be the Access Query itself as I did in my example below.

http://www.fmhs.uaeu.ac.ae/nml/Articles.asp

I hope that you find this useful

Best regards
Hisham




Lydecker -> RE: DRW within a DRW (9/5/2002 8:13:49)

so I really need to place them both in the same DataBase first.... correct? (but different tables)




hhammash -> RE: DRW within a DRW (9/5/2002 8:16:27)

Hi lydecker,

Yes, in the same database and in different tables. It will work fine.

Did you check the test page I setup for you?

Regards
Hisham




Lydecker -> RE: DRW within a DRW (9/5/2002 8:56:02)

Okay everyting is in one DB now. 2 Tables - 1 called ' Comments' the second called ' Results' .

In each returened record I wish to display the following:

From the Results Table
Date
Message
Picture
Name
Tiltle
ID

From the Comments Table
The number of comments for each ID value (i.e total up same ID values)

I guess a SQL query in Access is best. Thanks for the example, but you have left the Access SQL off :(

Thanks




hhammash -> RE: DRW within a DRW (9/5/2002 11:20:26)

Hi lydecker,


I left the SQL on the top of the second questions.


But also Access query will work.

Is it done now?


Regards
Hisham




Lydecker -> RE: DRW within a DRW (9/6/2002 8:49:58)

I' m affraid it doesnt work. Here is the code I am using:

SELECT Table1.ID, Table1.title, Table1.author, Count(comments.ID1) AS CountOfComments
FROM Table1 INNER JOIN comments ON Table1.ID=comments.ID1
GROUP BY Table1.ID, Table1.Title, Table1.author;




Cookie -> RE: DRW within a DRW (9/6/2002 8:56:12)

Hi,

I recently posted about creating a DRW within a DRW, and in the end I decided to just create the DRW in different cells. They dont overlap and I have a bout 4 DRW running on 1 page, and it works fine.

Dave




hhammash -> RE: DRW within a DRW (9/6/2002 8:59:12)

Hi Lydecker,

Is ID1 a FK in the second table and ID is the PK of the first table?

I prefer that the PK and FK to be the same name.

Look at my example, this code is working fine.

Regards
Hisham




hhammash -> RE: DRW within a DRW (9/6/2002 9:10:27)

Hi Lydecker,


[image]http://www.frontpagewebmaster.com/upfiles/5992/Ge95619.jpg[/image]




Lydecker -> RE: DRW within a DRW (9/6/2002 9:12:27)

What does FK stand for?

It is not possible for the two to have the same name [:(]

Thanks




Lydecker -> RE: DRW within a DRW (9/6/2002 9:18:03)

Oh - I' m getting somewhere. I changed the ID1 field to a ' number' value insctead of a ' text' one.

I have to dash for lunch - I' ll experiment more when I get back, Thanks!!




hhammash -> RE: DRW within a DRW (9/6/2002 9:20:26)

Hi Zac,

Table Articles has: ArticleID as Primary Key (PK)
Table Comments has: ArticleID as Foriegn Key (FK)
Articles table is related to Comments table via ArticleID



[image]http://www.frontpagewebmaster.com/upfiles/5992/Ay74677.jpg[/image]




Lydecker -> RE: DRW within a DRW (9/6/2002 9:40:47)

okay I have the primary key set in Table1, but don' t know how to set a forign key in the Comments Table[:(]

Thanks




Lydecker -> RE: DRW within a DRW (9/6/2002 9:45:22)

Okay - all working - just one problem!

If there are NO comments for a certain ID then no records are returned from the Table1 table.

If there are no comments for an ID then I wish the Table1 results still to be displayed, but with ' 0' in the ' CountOfComments' field instead of nothing returned. Follow?

Thanks

(ps my current code is:

SELECT Table1.ID, Table1.picture, Table1.news, Table1.eventone, Table1.eventtwo, Table1.title, Table1.author, Count(comments.ID1) AS CountOfComments
FROM Table1 INNER JOIN comments ON Table1.ID=comments.ID1
GROUP BY Table1.ID, Table1.Title, Table1.author, Table1.eventtwo, Table1.eventone, Table1.news, Table1.picture;




hhammash -> RE: DRW within a DRW (9/6/2002 9:46:58)

Hi,

In Article Table Click on ArticleID and then make it rimary Key
IN Comments table insert a field, call it ArticleID. Then Go to Relationships, Insert both tables, then Drage the ArticleID field from Article Tables and release it over the ArticleID in the Comments table, then press OK.

Don' t set any referrential integrity.

See my previous reply where I copied the relationships page for you.

Regards
Hisham




Lydecker -> RE: DRW within a DRW (9/6/2002 9:59:10)

THanks fo r that - now just the problem in my previous post remains.

Thank You




hhammash -> RE: DRW within a DRW (9/6/2002 13:42:38)

Hi Lydecker,

What are you doing to know if there is a comment or no. I mean when you fill in the table in Access what do you type in the column (comments) do you type the comment itself or you put a number?

Hisham




hhammash -> RE: DRW within a DRW (9/6/2002 13:54:57)

Hi Lydecker,

Look at my link again and see if this is what you want. If yes look below


1- Comments field in Access Database should be " Text" field not number.
2- If there is no comment keep it blank
3- In the Custom Query in Frontpage insert

SELECT DISTINCT articles.ArticleID, articles.Title, articles.Author, Count(comments.Comments) AS CountOfComments
FROM articles INNER JOIN comments ON articles.ArticleID = comments.ArticleID
GROUP BY articles.ArticleID, articles.Title, articles.Author;


Hope it works for you
Hisham




Lydecker -> RE: DRW within a DRW (9/6/2002 14:03:10)

The comments table is different to the article table. Just because someone submits data to the article table DOES NOT mean that they will submit any data to the comments table (follow?).

If you wish I can send you the db so you can see my db layout.

Thanks for the help[:p]




hhammash -> RE: DRW within a DRW (9/6/2002 15:59:40)

Hi Lydecker,

Would love too.

Email it to: hhammash@emirates.net.ae

Regards
Hisham




Lydecker -> RE: DRW within a DRW (9/6/2002 18:33:37)

It should be in your inbox[:D]

Thank you Hisham




hhammash -> RE: DRW within a DRW (9/6/2002 19:35:49)

Hi Lydecker,

Add another field and call it CommentSubject
Because we can not count the memo field, then this is the sql code:

SELECT Table1.ID, Table1.author, Table1.Title, Count(Comments.CommentSubject) AS CountOfCommentSubject
FROM Table1 LEFT JOIN Comments ON Table1.ID = Comments.ID1
GROUP BY Table1.ID, Table1.author, Table1.Title;

Left Join will take all fields from Table1 and all matching fields from Table2.

Note: Table1 should not have any Article ID that is not available in Table1, since ID is the primary key, otherwise the count will not appear.

In the database you sent, there was article ID 260 in comments which is not available in Table1.

Regards
Hisham




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
9.399414E-02