Click here to Skip to main content
11,635,626 members (79,798 online)
Rate this: bad
Please Sign up or sign in to vote.
Hi;I am trying to execute this code
    string sSql = "delete from Vacation where EmployeeID = ?";
               using (OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Feras\Documents\Visual Studio 2008\Projects\Manshiah\Manshiah\MansheyaDB_be.mdb"))
                   OleDbCommand command = new OleDbCommand(sSql, connection);
                   command.Parameters.AddWithValue("?", Convert.ToInt32(txtEmployeeId.Text));
                   OleDbDataReader myReader = command.ExecuteReader();
                       while (myReader.Read())
                           Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
                       // always call Close when done reading.
but it results this Exception: Deleted row information cannot be accessed through the row
Posted 3-Aug-12 3:42am
Edited 3-Aug-12 3:46am
Wes Aday102.2K

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Instead of
OleDbDataReader myReader = command.ExecuteReader();
I think you want to use
int numDeleted = command.ExecuteNonQuery();
And then obviously remove the myReader.Read() loop.

Here's a link for more information:[^]
feras.abulhaija at 3-Aug-12 10:40am
thanks a lot it is done and worked correctly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 8,861
1 Sergey Alexandrovich Kryukov 8,459
2 Mika Wendelius 6,849
3 F-ES Sitecore 2,354
4 Suvendu Shekhar Giri 2,270

Advertise | Privacy | Mobile
Web04 | 2.8.150728.1 | Last Updated 3 Aug 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100