设置断点调试,查看抛出的Exception信息。

解决方案 »

  1.   

    断点调试,看看sb1,formMainView是否为空!
      

  2.   

    上面的问题我已解决,问题出在formMainView,大家再帮我看看下面这个吧.
    private void treeViewMain_Click(object sender, System.EventArgs e)
    {
    TreeNode node=this.treeViewMain.SelectedNode;

    if(node != null)
    {
    string tabName = this.treeViewMain.SelectedNode.Text.Trim();
    System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();
    cmd.Connection = ClassGlobal.conMain;
    System.Data.DataSet ds = new System.Data.DataSet();

    if(tabName == "工作")
    {
    cmd.CommandText = "select * from 工作";
    }
    if(tabName == "工件")
    {
    cmd.CommandText = "select * from 工件";
    }
    if(tabName == "测站")
    {
    cmd.CommandText = "select * from 测站点坐标";
    }
    if(tabName == "基准尺")
    {
    cmd.CommandText = "select * from 基准尺";
    }
    if(tabName == "坐标系")
    {
    cmd.CommandText = "select * from 坐标系";
    }
    if((tabName=="2"||tabName=="1")&(node.Parent.Text.Trim()=="测站"))
    cmd.CommandText="select * from 测站定向观测测量数据";
    if(tabName=="1"&node.Parent.Text.Trim()=="基准尺")
                        cmd.CommandText="select * from 基准尺测量数据";
    System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(cmd);
    da.Fill(ds);
    this.dataGridMain.DataSource = ds.Tables[0];
    这个问题也是未将对象引用设置到对象的实例,问题出在node.Parent.Text.Trim()=="测站"(判断父接点),想不出怎么改,求求大家了,再帮我看以下.