Thank you!
posting the final code for anyone that can use it.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.IO;
using System.Globalization;
using System.Data.SqlClient;
namespace testupdate
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string strCvsFileName = "09760005.csv";
string pathOnly = Directory.GetCurrentDirectory();
string sql = @"SELECT * FROM [" + strCvsFileName + "]";
using (OleDbConnection connection = new OleDbConnection(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathOnly + ";Extended Properties=\"Text;HDR=YES\""))
using (OleDbCommand command = new OleDbCommand(sql, connection))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
DataTable dataTable = new DataTable();
dataTable.Locale = CultureInfo.CurrentCulture;
adapter.Fill(dataTable);
dataGridView1.DataSource = dataTable;
OleDbConnection DBconn = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=DATAGRP.MDB;");
DBconn.Open();
for (int i = 0; i < dataTable.Rows.Count; i++)
{
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = DBconn;
cmd.CommandText = "UPDATE INDEXDB1 SET IFIELD1= @IFIELD1, IFIELD2 = @IFIELD2, IFIELD3 = @IFIELD3, IFIELD4= @IFIELD4, IFIELD5 = @IFIELD5, IFIELD6 = @IFIELD6, IFIELD7 = @IFIELD7 WHERE IDNUM= @IDNUM";
cmd.Parameters.AddWithValue("@IFIELD1", dataTable.Rows[i].ItemArray.GetValue(1).ToString());
cmd.Parameters.AddWithValue("@IFIELD2", dataTable.Rows[i].ItemArray.GetValue(2).ToString());
cmd.Parameters.AddWithValue("@IFIELD3", dataTable.Rows[i].ItemArray.GetValue(3).ToString());
cmd.Parameters.AddWithValue("@IFIELD4", String.Format("{0:MM/dd/yyyy}", dataTable.Rows[i][4]));
cmd.Parameters.AddWithValue("@IFIELD5", String.Format("{0:MM/dd/yyyy}", dataTable.Rows[i][5]));
cmd.Parameters.AddWithValue("@IFIELD6", String.Format("{0:MM/dd/yyyy}", dataTable.Rows[i][6]));
cmd.Parameters.AddWithValue("@IFIELD7", dataTable.Rows[i].ItemArray.GetValue(7).ToString());
cmd.Parameters.AddWithValue("@IDNUM", dataTable.Rows[i].ItemArray.GetValue(0).ToString());
cmd.ExecuteNonQuery();
}
DBconn.Close();
}
}
}
}