0

I'm developing a social networking site where i'm facing problem when sending Friend Request from one user to another....The problem is that FriendRequest shows `` to every user not only to whom it send so i want to show that request to whom it send e.g: A send request to B so only B can see that request on FriendRequests.aspx just like facebook

I have these two pages

  1. People.aspx ...
  2. FriendRequests.aspx

Database table : FriendRequest.dbo

In People.aspx.....Subsonic Tool used...

FriendRequest obj = new FriendRequest();
obj.IsNew = true;
obj.Uid = Convert.ToInt32(Session["UserID"]);
obj.IsFriend = false;
obj.Save();

In FriendRequets.aspx

  if (!IsPostBack)
        {
            if (Session["UserID"] != null)
            {
                Response.Write(Session["FID"].ToString());
                DataTable dt = Helper.ExecutePlainQuery("select * from     UserRegistration inner join Profile on UserRegistration.uid=Profile.uid inner join FriendRequest on UserRegistration.uid=FriendRequest.uid");
                repeater1.DataSource = dt;
                repeater1.DataBind();
             }

In database table FriendRequest.dbo

ReqID int primary
uid int Foreign 
isFriend bit 

The design of these two pages just looks like facebook "People you may know" page and "Friend Requests" page

Kiran Hegde
  • 3,651
  • 1
  • 16
  • 14
Kumar
  • 41
  • 1
  • 11

1 Answers1

0

Your query should looke like this:

"SELECT * FROM UserRegistration 
 INNER JOIN Profile on UserRegistration.uid=Profile.uid 
 INNER JOIN FriendRequest on UserRegistration.uid=FriendRequest.uid 
 WHERE ReqID= " +  obj.Uid

by using WHERE you are filtering the result to only the ones where the ReqID matched the logged in user. On the assumption that ReqID is the person uid wants to be friends with.

Adam Copley
  • 1,495
  • 1
  • 13
  • 31
  • I'll take a look at this when I get home, in the meantime if you lookup 'prepared' statements, you will have some knowledge of using dynamic conditions in where clauses – Adam Copley Jan 28 '16 at 12:44
  • You need to pass `obj.Uid = Convert.ToInt32(Session["UserID"]);` into `FriendRequests.aspx`, and then my answer should work. – Adam Copley Feb 07 '16 at 03:29