日期:2014-05-18 浏览次数:20726 次
string connectionString = Properties.Settings.Default.dataConnectionString; int i = 0; DateTime gendate; OleDbConnection conn = new OleDbConnection(connectionString); if (chooselistbox.Items.Count == 0) { throw new Exception("没有数据存储"); } conn.Open(); while (i < chooselistbox.Items.Count) { string sql = "insert into tData(fCode,fGenDate) values(?,?) "; d.TryGetValue(chooselistbox.Items[i].ToString(), out gendate); OleDbCommand cmd = new OleDbCommand(sql, conn); cmd.Parameters.Add("?", OleDbType.VarChar, 50).Value = chooselistbox.Items[i]; cmd.Parameters.Add("?", OleDbType.Date).Value = gendate; cmd.ExecuteNonQuery(); i++; } conn.Close();