我有三个表,课程,教师,学生.我已经使用主键约束&来实现表之间的一对多关系.外键约束.我的设计由一个组合框和一个组合框组成.两个datagridviews.我将课程表的公共列绑定到combobox.当我选择combobox项时,它将在一个gridvie&中显示相应的教员表记录.在另一个gridview中的学生表记录.这些仅在窗体加载中.我在C#Windows窗体中得到结果.给定代码billow.但是在ASP中我没有得到相同的结果.为此,请给asp完整代码.使用关系概念. 私有void Form1_Load(对象发送者,EventArgs e) { 字符串cs ="uid = sa; pwd = nanda; database = satyadatabase"; SqlConnection conn =新的SqlConnection(cs); //conn.Open(); SqlCommand cmd1 =新的SqlCommand("select * from course",conn); SqlCommand cmd2 =新的SqlCommand("select * from faculty",conn); SqlCommand cmd3 =新的SqlCommand("select * from student",conn); SqlDataAdapter da2 =新的SqlDataAdapter(cmd); SqlDataAdapter da1 =新的SqlDataAdapter(cmd4); SqlDataAdapter da3 =新的SqlDataAdapter(cmd3); DataSet ds = new DataSet(); da1.Fill(ds,"coursenew"); da2.Fill(ds,"facultynew"); da3.Fill(ds,"studentnew"); ds.Relations.Add("coursefac",ds.Tables ["coursenew"].Columns ["courseid"],ds.Tables ["facultynew"].Columns ["courseid"]); ds.Relations.Add("coursest",ds.Tables ["coursenew"].Columns ["courseid"],ds.Tables ["studentnew"].Columns ["courseid"]); comboucname.DataSource = ds.Tables ["coursenew"]; comboucname.DisplayMember =课程名称"; gridfaculty.DataSource = ds.Tables ["coursenew"]; gridfaculty.DataMember ="coursefac"; gridstudent.DataSource = ds.Tables ["coursenew"]; gridstudent.DataMember =课程"; } [edit]仅标记-OriginalGriff [/edit]
I have three tables course,faculty,student.I have implemented one to many relation between tables using primary key constraint & foreign key constraint.my design consists of one combobox & two datagridviews.I bind the common column of course table to combobox.when i select the combobox item it will display corresponding faculty table records in one gridvie & student table records in another gridview.these are in form load only.I get the result in C# Windows forms.given the code billow.but i am not getting same result in ASP.For this give asp full code.please use relations concept. private void Form1_Load(object sender, EventArgs e) { string cs = "uid=sa;pwd=nanda;database=satyadatabase"; SqlConnection conn = new SqlConnection(cs); // conn.Open(); SqlCommand cmd1 = new SqlCommand("select * from course", conn); SqlCommand cmd2 = new SqlCommand("select * from faculty", conn); SqlCommand cmd3 = new SqlCommand("select * from student", conn); SqlDataAdapter da2 = new SqlDataAdapter(cmd); SqlDataAdapter da1 = new SqlDataAdapter(cmd4); SqlDataAdapter da3 = new SqlDataAdapter(cmd3); DataSet ds = new DataSet(); da1.Fill(ds, "coursenew"); da2.Fill(ds, "facultynew"); da3.Fill(ds, "studentnew"); ds.Relations.Add("coursefac", ds.Tables["coursenew"].Columns["courseid"], ds.Tables["facultynew"].Columns["courseid"]); ds.Relations.Add("coursest", ds.Tables["coursenew"].Columns["courseid"], ds.Tables["studentnew"].Columns["courseid"]); comboucname.DataSource = ds.Tables["coursenew"]; comboucname.DisplayMember = "coursename"; gridfaculty.DataSource = ds.Tables["coursenew"]; gridfaculty.DataMember = "coursefac"; gridstudent.DataSource = ds.Tables["coursenew"]; gridstudent.DataMember = "coursest"; } [edit]Tags only - OriginalGriff[/edit]
推荐答案您为什么希望我为您做功课?如果您遇到特定问题 ,请询问该问题. "Gimme codez"是疏远这里任何人的最好方法... Why would you expect me to do your homework for you? If you have a specific problem, please ask about it. "Gimme codez" is the best way to alienate anybody here...
添加到OriginalGriff所说的内容- 这是询问者的期望: 1. 先尝试您要做什么! 2.制定看起来像问题/无法解决的问题. 尝试一下,告诉您是否遇到问题. 成员将很乐意为您提供帮助. 看起来您说的是Winforms工作代码,但是无法在Webforms中工作?您认为两者的差异在哪里发生? Adding to what OriginalGriff said - Here is what is expected by enquirers: 1. TRY first what you want to do! 2. Formulate what was done by you that looks like an issue/not working. Try them and tell if you face issues. Members will be more than happy to help like this. Looks like you have a Winforms working code as you say and yet you are unable to get things working in Webforms? Where do you think the difference happens in both?
更多推荐
请提供asp.net代码
发布评论