我需要使用C#在Access 2000數據庫中插入一條記錄。代碼在SqlConnection失敗。請幫忙。將記錄插入到C#中的Access 2000數據庫中
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Trading.mdb";
string commandText = "INSERT INTO Order (OpenDate) VALUES (@OpenDate)";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(commandText, connection);
command.Parameters.AddWithValue("@OpenDate", DateTime.Now);
try
{
command.Connection.Open();
int response = command.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show("Error: {0}" + ex.Message);
}
}
它沒有去到代碼的SqlConnection後。 – Nicholas
首先,我想感謝所有發佈他們建議的人。它讓我思考,我已經想出瞭解決方案,雖然讀了很多帖子和反覆試驗這些示例代碼。 – Nicholas
我想問爲什麼我的帖子被擱置。關於這篇文章http://stackoverflow.com/questions/2415703/error-datatype-mismatch-in-c-sharp?爲什麼它不被擱置或任何類型的剋制?爲什麼這裏有雙重標準? – Nicholas