Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OleDb....   Exception handling

Posted on 2004-10-22
4
Medium Priority
?
382 Views
Last Modified: 2008-03-17
Hello,

is there a particular exception class that handles errors thrown by System.Data.OleDb?

thanks



0
Comment
Question by:brdrok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
Razzie_ earned 400 total points
ID: 12380842
Well yes there is the System.Data.OleDb.OleDbException class.
0
 
LVL 7

Author Comment

by:brdrok
ID: 12380949
hey Razzie,

thanks for the answer...got another question for you (increased point value to 100).  why does the code go to the "Exception" as opposed to the "System.Data.OleDb.OleDbException" catch block?

try
{
      string sqlString = "SELECT * FROM " + myRegion + " WHERE Status_FK = " + myStatus;
      System.Data.OleDb.OleDbConnection myConn = new OleDbConnection(CONNSTRING);
      System.Data.OleDb.OleDbDataAdapter myDA = new OleDbDataAdapter();  <---i create a mistake here
      System.Data.DataSet myDS = new DataSet();
      myDA.Fill(myDS, "ProgressReport");   <----Exception is thrown here and goes to the "Exception" catch block.
}
catch (System.Data.OleDb.OleDbException oleEx)
{
                MessageBox.Show(oleEx.Message);
      return;
}
catch (Exception ex)
{
      MessageBox.Show(ex.Message);
      return;
}
finally
{
      //TODO: DO CLEAN UP HERE
}
0
 
LVL 8

Expert Comment

by:Razzie_
ID: 12381102
OleDbExceptions are only thrown when something goes wrong at the server, for example invalid table name, non-existend column names, etc.

The error you create (not setting the select query) is an InvalidOperationException. It doesn't have anything to do with the actual database data, or table structures.

I think that when you enter something invalid in your sql query, like an invalid table name, the OleDbException will be thrown.

HTH,

Razzie
0
 
LVL 7

Author Comment

by:brdrok
ID: 12381914
Thanks Razzie for the very useful info.....

you rock....
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question