Home All Groups Group Topic Archive Search About

OLEDB Exception: The search key was not found in any record

Author
25 Jan 2006 9:43 PM
temp
Greetings!

I've written a console application to perform some trivial database
routines.  When I run the application, it catches the an OleDbException
that states "The search key was not found in any record."  My C# code
follows:

=============== snip ==========================
OleDbCommand cmd = new OleDbCommand(sqlstmt, new
OleDbConnection(cnct));

try
{
    cmd.Connection.Open();
    cmd.ExecuteNonQuery();
    cmd.Connection.Close();
}
catch(Exception e)
{
    Console.WriteLine(e.Message);
    Console.Read();  // used to pause application long enough to read
message
}

cmd.Dispose();
=============== snip ==========================

sqlstmt = "DELETE FROM Accounts WHERE AccountID > 3"
cnct = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA
SOURCE=data_source;Persist Security Info=False;Jet OLEDB:Database
Password=password"
where data_source is the fully qualified local path of the database and
password is, well, obvious (I hope).

I've checked the database and it contains the Accounts table and
AccountID column.  The AccountID column does have numbers greater than
three.

I have run this application before in the past with success.  It is an
enigma to me why it is no longer functioning.  I did recently install
the .NET Framework 2.0 update, but even after uninstalling it, I still
received the exception.

Any assistance that could be provided would be greatly appreciated.

Thanks.

Tim

Author
27 Jan 2006 5:08 PM
Milosz Skalecki
This error often means that the database has become corrupted.
To coerrect the error the database needs to be repaired. If the database is
on a remote server download the database and foillow the instructions below
to repair the database. Open the database in Microsoft Access, click on the
'Tools' menu and select 'Database Utilities -> Compact and Repair Database'.
or
http://support.microsoft.com/?id=301474

--
Milosz Skalecki
MCP, MCAD


Show quote
"t***@whocallmetim.net" wrote:

> Greetings!
>
> I've written a console application to perform some trivial database
> routines.  When I run the application, it catches the an OleDbException
> that states "The search key was not found in any record."  My C# code
> follows:
>
> =============== snip ==========================
> OleDbCommand cmd = new OleDbCommand(sqlstmt, new
> OleDbConnection(cnct));
>
> try
> {
>     cmd.Connection.Open();
>     cmd.ExecuteNonQuery();
>     cmd.Connection.Close();
> }
> catch(Exception e)
> {
>     Console.WriteLine(e.Message);
>     Console.Read();  // used to pause application long enough to read
> message
> }
>
> cmd.Dispose();
> =============== snip ==========================
>
> sqlstmt = "DELETE FROM Accounts WHERE AccountID > 3"
> cnct = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA
> SOURCE=data_source;Persist Security Info=False;Jet OLEDB:Database
> Password=password"
> where data_source is the fully qualified local path of the database and
> password is, well, obvious (I hope).
>
> I've checked the database and it contains the Accounts table and
> AccountID column.  The AccountID column does have numbers greater than
> three.
>
> I have run this application before in the past with success.  It is an
> enigma to me why it is no longer functioning.  I did recently install
> the .NET Framework 2.0 update, but even after uninstalling it, I still
> received the exception.
>
> Any assistance that could be provided would be greatly appreciated.
>
> Thanks.
>
> Tim
>
>
Author
9 Feb 2006 1:34 AM
temp
That appears to have been the case.  Thanks for your assistance.

Milosz Skalecki wrote:
Show quote
> This error often means that the database has become corrupted.
> To coerrect the error the database needs to be repaired. If the database is
> on a remote server download the database and foillow the instructions below
> to repair the database. Open the database in Microsoft Access, click on the
> 'Tools' menu and select 'Database Utilities -> Compact and Repair Database'.
> or
> http://support.microsoft.com/?id=301474
>
> --
> Milosz Skalecki
> MCP, MCAD
>
>
> "t***@whocallmetim.net" wrote:
>
> > Greetings!
> >
> > I've written a console application to perform some trivial database
> > routines.  When I run the application, it catches the an OleDbException
> > that states "The search key was not found in any record."  My C# code
> > follows:
> >
> > =============== snip ==========================
> > OleDbCommand cmd = new OleDbCommand(sqlstmt, new
> > OleDbConnection(cnct));
> >
> > try
> > {
> >     cmd.Connection.Open();
> >     cmd.ExecuteNonQuery();
> >     cmd.Connection.Close();
> > }
> > catch(Exception e)
> > {
> >     Console.WriteLine(e.Message);
> >     Console.Read();  // used to pause application long enough to read
> > message
> > }
> >
> > cmd.Dispose();
> > =============== snip ==========================
> >
> > sqlstmt = "DELETE FROM Accounts WHERE AccountID > 3"
> > cnct = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA
> > SOURCE=data_source;Persist Security Info=False;Jet OLEDB:Database
> > Password=password"
> > where data_source is the fully qualified local path of the database and
> > password is, well, obvious (I hope).
> >
> > I've checked the database and it contains the Accounts table and
> > AccountID column.  The AccountID column does have numbers greater than
> > three.
> >
> > I have run this application before in the past with success.  It is an
> > enigma to me why it is no longer functioning.  I did recently install
> > the .NET Framework 2.0 update, but even after uninstalling it, I still
> > received the exception.
> >
> > Any assistance that could be provided would be greatly appreciated.
> >
> > Thanks.
> >
> > Tim
> >
> >

AddThis Social Bookmark Button