关于DATAGRIDVIEW如何显示关联的表?
这个是我的代码,但是没有效果,显示的还是一张表,最后一句代码改成别的也不成,但是看啊《C#数据库入门经典》和这个差不多啊,查MSDN也不知道哪里错了,帮忙看看~~谢谢SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\nn\Documents\Visual Studio 2008\Projects\CONNECT\tkfinal1.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlCommand cmd = new SqlCommand();
conn.Open();
= "select s_no AS 题号,s_sub AS 题目,s_sco AS 分数,s_tchno AS 教师编号 from SUBJECT "+" SELECT s_no AS 题号,s_ans AS 答案 FROM ANSWER";
SqlDataAdapter da = new SqlDataAdapter(, conn);
DataSet ds1 = new DataSet();
da.Fill(ds1);
DataRelation dr = new DataRelation("all", ds1.Tables[0].Columns[0], ds1.Tables[1].Columns[0]);
ds1.Relations.Add(dr);
dataGridView1.DataSource = ds1.Tables[0];