vb c#IErrorInfo.GetDescription失败并带有E_FAIL(0x80004005)

时间:2016-03-08 15:02:18

标签: c#

我无法保存文件。请帮忙。这是我的代码

private void cmdsave_Click(object sender, EventArgs e)
{
    //x = 0;
    con();
    sqlcommand.CommandText = "SELECT * FROM tblname WHERE PCode = '" + txtlname.Text + "' AND PName = '" + txtfname.Text + "' AND Quantity = '" + txtmname.Text + "' AND Section = '" + textBox2.Text + "' ";
    sqlcommand.Connection = connect;
        OleDbDataReader reader = sqlcommand.ExecuteReader();

    while (reader.Read())
    {x++;}
    if (x != 0)
    {
        MessageBox.Show("Duplicate record(s) found...");                
    }
    else
    {
        if (mode == "a")
        {   
            con();
            sqlcommand.CommandText = "INSERT INTO tblname (PCode, PName, Quantity, Section) VALUES ('" + txtlname.Text + "', '" + txtfname.Text + "', '" + txtmname.Text + "', '" + textBox2.Text + "') ";
            sqlcommand.Connection = connect;
            reader = sqlcommand.ExecuteReader();
            MessageBox.Show("Record(s) Saved", "Sample");
        }
        else if (mode == "e")
        {
            con();
            sqlcommand.CommandText = "UPDATE tblname SET PCode = '" + txtlname.Text + "', PName = '" + txtfname.Text + "', Quantity = '" + txtmname.Text + "' , Section = '" + textBox2.Text + "' WHERE ID = " + idholder + "  ";
            sqlcommand.Connection = connect;
            reader = sqlcommand.ExecuteReader();
            MessageBox.Show("Record(s) Updated", "Sample");
        }
    }
    connect.Close();
    idholder = "";
    cncel();     
}

我只是添加了部分(textBox2)。在添加这些代码之前,程序运行正确。

enter image description here

0 个答案:

没有答案