By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,083 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,083 IT Pros & Developers. It's quick & easy.

Help: System.Data.OleDb.OleDbException Error

P: n/a
Friends,

The following code works fin. BUT...
after a >> couple times<< this code is used is a class it comes with an
error saying
unhandled System.Data.OleDb.OleDbException' occurred in system.data.dll
Any suggestions what could be wrong.

public int LeesRadSoort( string radcode ) {

string sSQL = "SELECT * FROM Rad WHERE RadCode = '" + radcode + "';";

OleDbConnection cnnSCORE = new OleDbConnection();

cnnSCORE.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
source= C:\Scorwin\data \Data.mdb";

cnnSCORE.Open();

OleDbCommand cmdSQL = new OleDbCommand(sSQL, cnnSCORE);

OleDbDataReader sdrSCORE = cmdSQL.ExecuteReader();

/// code that is making some calculations -> result

CnnSCORE.Close();

return result

}

Regards

gerrit esmeijer

(Netherlands)




Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
G.Esmeijer wrote:
Friends,

The following code works fin. BUT...
after a >> couple times<< this code is used is a class it comes with an
error saying
unhandled System.Data.OleDb.OleDbException' occurred in system.data.dll
Any suggestions what could be wrong.

public int LeesRadSoort( string radcode ) {

string sSQL = "SELECT * FROM Rad WHERE RadCode = '" + radcode + "';";

OleDbConnection cnnSCORE = new OleDbConnection();

cnnSCORE.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
source= C:\Scorwin\data \Data.mdb";

cnnSCORE.Open();

OleDbCommand cmdSQL = new OleDbCommand(sSQL, cnnSCORE);

OleDbDataReader sdrSCORE = cmdSQL.ExecuteReader();

/// code that is making some calculations -> result

CnnSCORE.Close();

return result

}


enclose the ExecuteReader() statement with a try/catch clause andCatch the
OleDbException. In that exception, you'll find an Errors collection which
contains the actual error. See the OleDbException docs for details. By
checking this collection, you can determine what's wrong.

FB
--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #2

P: n/a
Frans,

Thanks for your reply... however, in spite of the fact that I have done what
you suggested, this error is not caught by the try catch construction. I
keeps pointing at the same line and the error is not caught. Thanks anyway

Gerrit Esmeijer
"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> schreef in bericht
news:xn***************@msnews.microsoft.com...
G.Esmeijer wrote:
Friends,

The following code works fin. BUT...
after a >> couple times<< this code is used is a class it comes with an
error saying
unhandled System.Data.OleDb.OleDbException' occurred in system.data.dll
Any suggestions what could be wrong.

public int LeesRadSoort( string radcode ) {

string sSQL = "SELECT * FROM Rad WHERE RadCode = '" + radcode + "';";

OleDbConnection cnnSCORE = new OleDbConnection();

cnnSCORE.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
source= C:\Scorwin\data \Data.mdb";

cnnSCORE.Open();

OleDbCommand cmdSQL = new OleDbCommand(sSQL, cnnSCORE);

OleDbDataReader sdrSCORE = cmdSQL.ExecuteReader();

/// code that is making some calculations -> result

CnnSCORE.Close();

return result

}


enclose the ExecuteReader() statement with a try/catch clause andCatch the
OleDbException. In that exception, you'll find an Errors collection which
contains the actual error. See the OleDbException docs for details. By
checking this collection, you can determine what's wrong.

FB
--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP

Nov 16 '05 #3

P: n/a
G.Esmeijer wrote:
Frans,

Thanks for your reply... however, in spite of the fact that I have done what
you suggested, this error is not caught by the try catch construction. I
keeps pointing at the same line and the error is not caught. Thanks anyway
What's the code after you've enclosed the code with try/catch statements? If
the code you originally posted throws an OleDbException, it has to end up in
the catch. Did you position the try statement at the right spot? Could you
post that snippet with the try/catch?

Frans.

Gerrit Esmeijer
"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> schreef in bericht
news:xn***************@msnews.microsoft.com...
G.Esmeijer wrote:
Friends,

The following code works fin. BUT...
after a >> couple times<< this code is used is a class it comes with an
error saying
unhandled System.Data.OleDb.OleDbException' occurred in system.data.dll
Any suggestions what could be wrong.

public int LeesRadSoort( string radcode ) {

string sSQL = "SELECT * FROM Rad WHERE RadCode = '" + radcode + "';";

OleDbConnection cnnSCORE = new OleDbConnection();

cnnSCORE.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data
source= C:\Scorwin\data \Data.mdb";

cnnSCORE.Open();

OleDbCommand cmdSQL = new OleDbCommand(sSQL, cnnSCORE);

OleDbDataReader sdrSCORE = cmdSQL.ExecuteReader();

/// code that is making some calculations -> result

CnnSCORE.Close();

return result

}


enclose the ExecuteReader() statement with a try/catch clause andCatch the
OleDbException. In that exception, you'll find an Errors collection which
contains the actual error. See the OleDbException docs for details. By
checking this collection, you can determine what's wrong.

--
Get LLBLGen Pro, the new O/R mapper for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.