Here is the working code
string strProvier = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Employees.mdb";
OleDbConnection con = new OleDbConnection(strProvier);
OleDbCommand cmd = new OleDbCommand();
int effectedRow = 0;
int lineCounter = 0;
con.Open();
if ((con.State.ToString() == "Open"))
{
StreamReader stReader = new StreamReader("Employees.csv");
string[] strRowData = null;
while (stReader.Peek() >= 0)
{
lineCounter = lineCounter + 1;
strRowData = stReader.ReadLine().Split(",");
try {
cmd.CommandText = "INSERT INTO tbl_employees(emp_first_name,emp_last_name,emp_salary) VALUES ('" + strRowData(0) + "','" + strRowData(1) + "','" + strRowData(2) + "')";
cmd.Connection = con;
effectedRow = cmd.ExecuteNonQuery();
if ((effectedRow == -1)) {
// Messagebox.Show("Line: " + lineCounter + " Error");
}
else {
// Messagebox.Show("Line: " + lineCounter + " Executed Successfully");
}
}
catch (OleDbException er) {
Messagebox.Show("Line: " + lineCounter + " Error: " + er.Message);
}
}
stReader.Close();
con.Close();
}
else {
Messagebox.Show("Not Connected To Database");
}
Try this and let em know.