i want join two tables in sql server how? [Resolved]

Posted by Chandru_ra under Sql Server on 6/28/2011 | Points: 10 | Views : 1992 | Status : [Member] | Replies : 6
Dear All,

public void GetDetailForum()
{

SqlConnection con = new SqlConnection(strCS);
SqlDataAdapter da = new SqlDataAdapter("select Author,forumID,forumTitle,forumDesc,Images from tblForum where forumID='" + Request.QueryString["forumID"] + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}

public void GetResponses()
{

SqlConnection con = new SqlConnection(strCS);
SqlDataAdapter da = new SqlDataAdapter("select responseby,responseID,GradeLevel,Points,responsemsg,Dateofpost,Convert(CHAR(10),Dateofpost,101) as Jdate from tblForumResponse where forumID='" + Request.QueryString["forumID"] + "' order by Dateofpost desc", con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
}
this two tables join result for latest response in the forums displayed in first page which join use help me

Advance Thanks to all

chandru


Responses

Posted by: PandianS on: 6/28/2011 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
Hi

Try this...
select FR.responseby,FR.responseID,FR.GradeLevel,FR.Points,FR.responsemsg,FR.Dateofpost,Convert(VARCHAR(10),FR.Dateofpost,101) as Jdate from tblForum F With (Nolock) JOIN tblForumResponse FR With (Nolock) On (F.forumID = FR.forumID) Where F.forumID = @forumID order by FR.Dateofpost desc
Cheers
www.sqlserverbuddy.blogspot.com


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandru_ra on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
hi,
ur query is forum response is first in the page.. but i want forums displayed in top of the page..


chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
hi you want combine two tables no need to write two functions
try this
sqldataadapter da=new sqldataadapter("select f.col1,f.col2,....,s.col1,s.ccol2..... from table1 f inner join table2 s on f.col1=s.col1 where f.col1='"+ giveinput +"'",con);


Thanks&Regards
LakshmiNarayana Nalluri.

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandru_ra on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
hi,
am posted one forums 28-06-11 and form response is 30-06-11 for users but forums displayed again top 1 st in the table..

Thanks advance

chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: PandianS on: 6/28/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Chandru_ra

Kindly post your question little clear.... Please!

If you want the answer then post your question little clear...
(or)
If you want to say something to the Site Author then Kindly choose the Category as 'DotnetFunda.Com'

Cheers

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chandru_ra on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
hi,
am forum and forum response in two table. am post a new forum in display for table in first..after two weeks that forum in table last field. any users that forums any response for that forums display in the first in table..

Thanks advance all

chandru

Chandru_ra, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response