求大神看下~

u010667428 2017-09-08 08:46:15
以下为部分代码
		#region 加载数据
private void DataLoad()
{
bool bOpen=(this.connMain.State==System.Data.ConnectionState.Open);
try
{
if(!bOpen)
{
this.connMain.Open();
}
if(this.dataset11.Tables["PropertyZZJG"]!=null)
{
this.dataset11.Tables["PropertyZZJG"].Clear();
}
this.daMaster.SelectCommand.CommandText=@"select * from PropertyZZJG order by CurrentId";
this.daMaster.Fill(this.dataset11,"PropertyZZJG");


if(this.dataset11.Tables["PropertyUser"]!=null)
{
this.dataset11.Tables["PropertyUser"].Clear();
}
this.daUser.SelectCommand.CommandText=@"select * from PropertyUser";
this.daUser.Fill(this.dataset11,"PropertyUser");
}
catch(System.Exception ee)
{
MessageBox.Show(ee.Message,"系统提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
finally
{
if(!bOpen)
{
this.connMain.Close();
}
}
}
#endregion

private void ReadTreeNodes1()
{
if(this.TV_ZZJG.Nodes!=null)
{
this.TV_ZZJG.Nodes.Clear();
}
System.Data.DataRow[] dr=this.dtUser.Select("DepartmentID = "+this.TV_Department.SelectedNode.Tag.ToString());
for(int i=0;i<dr.Length;i++)
{
TreeNode tn=new TreeNode();
tn.Text=dr[i]["User_Name"].ToString();
tn.Tag=dr[i]["Master_Id"].ToString();
tn.ImageIndex=0;
tn.SelectedImageIndex=1;
this.TV_ZZJG.Nodes.Add(tn);
}



结果图如下


...全文
131 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
APP开发王 2017-09-08
  • 打赏
  • 举报
回复
daUser 为 null,加个判断 在执行吧 if (daUser !=null) {}
exception92 2017-09-08
  • 打赏
  • 举报
回复
dauser,dtuser 可能为null,调试你的程序,具体看看它们的只,代码中没有看到对它们的实例化。 http://www.cnblogs.com/alexis/archive/2010/11/06/1870519.html

110,569

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧