我正在尝试编写将日期插入到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!!");
}
}