Solved

Internal Messaging System ASP.NET

Posted on 2009-04-13
10
807 Views
Last Modified: 2012-05-06
Hi there i want to set up a very very simple internal messaging system...

Pages:
DefaultMessages.aspx --> Displays two links for, 1: Inbox, 2: Compose New Message
MessagesInbox.aspx --> Displays all the Messages that user received from other users
MessagesNew.aspx --> Make new messages to send

My Access DB is:
tblUsers --> UserID, Username, Password, Firstname, Lastname
tblPMMessages --> pmID, pmSubject, pmContent, MessageFrom, MessageTo

How do i setup this to work, do i need to have a relation between UserID --> MessageFrom and UserID --> MessageTo

I don't understand the logic here...Can anyone explain how i would need to setup this to make it work, if anyone just can push me in right direction...
0
Comment
Question by:Neste
  • 5
  • 5
10 Comments
 
LVL 15

Expert Comment

by:oobayly
ID: 24130293
If you're looking for the SQL query to to get all the messages sent to a particular user, this should do the job:
Of course, you'll want to select only the required fields rather than everything.
SELECT *

FROM tblPMMessages

INNER JOIN tblUsers ON tblPMMessages.fldMessageFrom = tblUsers.fldUserID

WHERE tblPMMessages.fldMessageTo = ?

Open in new window

0
 

Author Comment

by:Neste
ID: 24136397
I have worked whit your example and i ended up with the code provided...

It works but how do i Display the Username instead for the ID...

When a user checks his/hers Inbox, i want them to know who the messages are from...

As it is now it only displays numbers/ids....
"SELECT * FROM [tblPMMessages], [tblUsers]" & _

"WHERE [tblPMMessages.MessageFromID] = [tblUsers.UserID]" & _

"AND [tblPMMessages.MessageToID] = @id"

Open in new window

0
 
LVL 15

Accepted Solution

by:
oobayly earned 125 total points
ID: 24136504
What database server are you using? If you're using the query posted you should be receiving all fields from all tables specified in the query.
Also, you shouldn't really need the square brackets unless you have a table or field that shares a name with a keyword. ie Calling a field "Sum", or a table "View".
I'm also vaguely surprised that [tblPMMessages.MessageToID] works, as this implies that the field name is "tblPMMessages.MessageToID", not the field "MessageToID" in the table "tblPMMessages", of course this may depend on the database server.

You could of course specify the fields yourself.
SELECT

  [tblUsers].[Firstname], [tblUsers].[LastName],

  [tblPMMessages].[pmSubject], [tblPMMessages].[pmContent]

FROM [tblPMMessages], [tblUsers]

WHERE [tblPMMessages].[MessageFromID] = [tblUsers].[UserID]

AND [tblPMMessages].[MessageToID] = @id

Open in new window

0
 

Author Comment

by:Neste
ID: 24136603
I am using MS Access...

Instead of MessageFromID i want to display the username from tblUsers...

0
 

Author Comment

by:Neste
ID: 24136618
here is the aspx code...

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataKeyNames="pmID">
        <Columns>
            <asp:BoundField DataField="pmID" HeaderText="pmID" InsertVisible="False"
                ReadOnly="True" SortExpression="pmID" />
            <asp:BoundField DataField="pmSubject" HeaderText="pmSubject"
                SortExpression="pmSubject" />
            <asp:BoundField DataField="pmContent" HeaderText="pmContent"
                SortExpression="pmContent" />
            <asp:BoundField DataField="pmCreateDate" HeaderText="pmCreateDate"
                SortExpression="pmCreateDate" />
            <asp:BoundField DataField="MessageToID" HeaderText="MessageToID"
                SortExpression="MessageToID" />
            <asp:BoundField DataField="MessageFromID" HeaderText="MessageFromID"
                SortExpression="MessageFromID" />
        </Columns>
    </asp:GridView>
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 15

Expert Comment

by:oobayly
ID: 24136641
Have you tried the query I posted, it should show the sender's name. All your should have to do is add a similar field for "Username"
0
 

Author Comment

by:Neste
ID: 24136655
yeah it works now thx m8

just added:            
<asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
0
 

Author Comment

by:Neste
ID: 24136714
Any quick ides for an Insert command for this ?
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24136753
Right, now I get you. Just change "MessageFromID" to "Username" for all the attributes in the BoundField tag
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24136814
Should be as simple as this, assuming that pmID in an auto increment field
INSERT INTO tblPMMessages(pmSubject, pmContent, MessageFrom, MessageTo)

VALUES(@pmSubject, @pmContent, @MessageFrom, @MessageTo)

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now