你能帮我解决这个错误((system.data.oledb exception(0x80040e14))?

时间:2019-05-16 15:51:32

标签: c# visual-studio ms-access-2010

我正在尝试编写将日期插入到ms Access数据库中的代码,但是在运行此代码并按下按钮后,它会在异常处理消息框中显示错误消息:

  

systen.data.oledb异常(0x80040e14)

我尝试使用参数,它给出了相同的消息:

    private void button1_Click_1(object sender, EventArgs e)
    {
        try
        {
            OleDbConnection connection = new OleDbConnection();
            connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\TravelAgency\DataBase\ProjectDataBAse.accdb;
            Persist Security Info=False;";
            connection.Open();
            OleDbCommand command = new OleDbCommand();
            command.Connection = connection;
            command.CommandText="insert into flights(from,to,Fdate,offtime,arrtime,price) values('"+fromTextBox.Text+"','"+
                toTextBox.Text+"','"+fdateDateTimePicker.Text+"','"+offtimeTextBox.Text+"','"+arrtimeTextBox.Text+"','"
                +priceTextBox.Text+"')";
            command.ExecuteNonQuery();
            connection.Close();
        }
        catch(Exception ex)
        {
            MessageBox.Show(ex.ToString(), "Error!!");
        }
    }

0 个答案:

没有答案