Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am working in ASP.net with linq and C# and SQL server database
i have three tables s_reg,s_log,s_prof
from which i want to get the data from s_reg and s_prof table
s_reg have reg_id,s_prof have stud_id as primary key and s_prof have reg_id as foreign key
i want to show some fields from s_reg and some from s_prof


thanks in advance

What I have tried:

protected void Page_Load(object sender, EventArgs e)
    {
        s_prof prof = new s_prof();
        s_reg reg = new s_reg();
        s_log slog = new s_log();
        studentDataContext db = new studentDataContext();
        if (Session["usernm"] == null)
        {
            Console.WriteLine("ERRORRRRR");
        }
        else
        {
            var log = (from s in db.s_profs
                   join m in db.s_regs on s.reg_id equals m.reg_id
                   where m.susnm == Convert.ToString(Session["usernm"])
                   select new { s.stdname, s.stdcity, s.stdmob,s.stdemail,m.smobile});

           
            TextBox1.Text = prof.stdname;
            TextBox2.Text = prof.stdcity;
            TextBox3.Text = prof.stdmob;
            TextBox4.Text = prof.stdemail;
            TextBox5.Text = reg.smobile;
        }
        
    }
}
Posted
Comments
CHill60 24-Apr-18 5:00am    
What is the problem with what you have tried?
Member 13686623 24-Apr-18 5:19am    
textboxes are not showing any data even though i have added 4-5 records in the tables
Member 13686623 24-Apr-18 5:20am    
it is not showing any error but neither result
Richard MacCutchan 24-Apr-18 6:19am    
You are selecting your database records into a variable named log. But you then try to populate your textboxes from variables prof and reg which do not contain anything.
Member 13686623 24-Apr-18 7:12am    
so what should i try please suggest...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900