When I use an add command to add data to an Access dB, supposing that db doesn't exist or a connection is lost to the dB or anything atall, and my VB program returns an error to my program, rather than allowing it to crash is there an error code that gets returned that I can use to handle the program execution appropriately
thanks
tattoo

Error codes
magikalpnoi
I have been using the Try Catch block but I guess my problem was how to handle the error.
Your explanation of reading the documentation makes sense. One of my problems is If I use the following to do an Update
DataAdatper.Update(Dataset, "Table_Name") I'm not sure which is the Class in that statement...
I came from an IBM AS/400 environment and am just getting used to this whole OOP methodology...
thanks for your patience.
tattoo
N. Farr
Thanks once again.
this helps me a lot..
Larry Smith
place a try catch block around where you think the error would most likely happen, or rather, read the documentation on the class to see what errors/exceptions it will throw and place the try catch block around it. Example:
Dim theOleDbConnection as new OleDbConnection(connectionString)
Dim theOleDbCommand as new OleDbCommand(commandHere)
theOleDbCommand.Connection = theOleDbConnection
try
theOleDbConnection.Open() 'when you open the connection, errors can happen such as invalid connection string or server not reachable etc...
theOleDbCommand.ExecuteNonQuery() 'exception will be thrown if the query is incorrect/not valid
catch ex as OleDbException
'handle the exception
finally
theOleDbConnection.Close()
end try
R.S.N
no worries at all. Usually when you type code in Visual Studio and you access a method, a tooltip appears with info about that method, sometimes it gives you the list of exceptions that will be thrown by executing that method, so you know you need to implement the exceptions around it.
Now, when an exception is thrown, it goes into the catch block. So in here, you handle the error any way you want. There is no 1 way of handling the error. The most common way I guess would be to notify the user on what the error was and then do whatever you need to do.
It depends entirely on your application, its purpose, what its doing at the time of the error etc....
Looking at the docs in your example for the Update() command, it will throw an InvalidOperationException or an DBConcurrencyException. You can of course access the docs for the exception on what they mean and in what situation these exceptions would be thrown to give you a better understanding. Usually with any method that performs some action, if an exception is to be thrown, it will be stated in the docs what exceptions and why they would be thrown
Things like for example connecting to the database, if a connection cannot be made, an exception will be thrown, which you catch and check the connection exception message (perhaps look at the error code of the exception and see what it means in the docs) then display a message to the user that the connection could not be made for whatever reason.