我有一个包含7个字段的Access文件:
DocID - text - primary
SourceID - text
ReceivedDay - Date/Time
Summary - text
DueDay - Date/Time
Person - text
Status - Yes/No
Run Code Online (Sandbox Code Playgroud)
现在我想用以下代码更新此文件:
const string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\DocMan.mdb;Persist Security Info=True";
const string InsertQuery = "INSERT Into Docs(DocID,ReceivedDay,Summary,Person,DueDay,Status,SourceID) Values(@DocID,@ReceivedDay,@Summary,@Person,@DueDay,@Status,@SourceID)";
string DocID = textBox1.Text;
string SourceID = comboBox1.SelectedIndex.ToString();
DateTime ReceivedDay = dateTimePicker1.Value;
string Summary = richTextBox1.Text;
string Person = textBox2.Text;
DateTime DueDay = dateTimePicker2.Value;
bool Status = false;
OleDbConnection cnn = new OleDbConnection(ConnectionString);
cnn.Open();
OleDbCommand cmd = new OleDbCommand(InsertQuery, …Run Code Online (Sandbox Code Playgroud)