对象引用未设置为提交按钮上的对象实例

时间:2015-05-26 06:42:54

标签: c# window

请帮忙。 当我点击提交按钮,所以我收到一个错误。请帮帮我

        try
        {
            btnUpload.Visible = true;

            con = new SqlConnection("Data Source=.;Initial Catalog=DSIIDC2;Integrated Security=True");
            con.Open();
            string str = "insert into addcaasedetails(caseno,casetype) values(" + txtcaseno.Text + ",'" + txtcasetype.Text + "')";
            cmd = new SqlCommand(str, con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);


            if (ds.Tables["addcaasedetails"] == txtcaseno.Text && ds.Tables["addcaasedetails"].ToString()==txtcasetype.Text.ToString())
            {
                btnUpload.Visible = false;
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

0 个答案:

没有答案