标题:[求助]多表查询
只看楼主
Flying12
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-4-2
 问题点数:0 回复次数:0 
[求助]多表查询

各位能帮我看看是那里出了错嘛,,
单表(basic)查询时正常..但多表查询就要出错..谢谢了

string SqlSel;
SqlSel = "select Number,Age,Name,Native,Tel,Sex,Email,Folk,DeptName,DDuty from basic "+
"INNER JOIN Dept ON basic.DeptID = Dept.DeptID"+
"where(basic.Number = number)";

SqlCommand sqlComm = new SqlCommand(SqlSel,sqlConnection1);
this.sqlConnection1.Open();
SqlDataReader dr = sqlComm.ExecuteReader();
try
{
if(dr.Read())
{
txtName.Text = dr["Name"].ToString();
this.txtAge.Text = dr["Age"].ToString();
this.txtSex.Text = dr["Sex"].ToString();
this.txtTel.Text = dr["Tel"].ToString();
this.txtNative.Text = dr["Native"].ToString();
this.txtMail.Text = dr["Email"].ToString();
this.txtFolk.Text = dr["Folk"].ToString();

this.txtDept.Text = dr["DeptName"].ToString();
this.txtDuty.Text = dr["DDuty"].ToString();
}
DeptName和DDuty是Dept表的数据.

搜索更多相关主题的帖子: 查询 
2006-04-22 09:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-59209-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.981805 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved