Hi, I am learning how to work with DataBases. I found some code on the internet
that creates a database. Everything Works fine, but I am trying to make sense of what everything does.
After doing some research I found out that the try,catch,finally keywords are good for error handling, however its what is within the try catch finally blocks that I am trying to understand.
This part I know creates a variable name cat as new catalog, but what does the catalog do?
All that I figured out here was that it creates a db to the specified source, but what does the provider=microsoft.jet.oledb.4.0. do.
I know that catch is executed if try doesnt work and it "gracefully" handles the error, but I am not sure in detail. COuld someone explain this line
Catch Excep As System.Runtime.InteropServices.COMException
Sorry if I asked to many questions
that creates a database. Everything Works fine, but I am trying to make sense of what everything does.
After doing some research I found out that the try,catch,finally keywords are good for error handling, however its what is within the try catch finally blocks that I am trying to understand.
VB.NET:
Dim cat As New Catalog()
This part I know creates a variable name cat as new catalog, but what does the catalog do?
VB.NET:
Try
'Create NewDB Database.
'Change the path to the new .mdb file as appropriate. Make sure the folder
'provided in the path exists. If you path name is not specified, the
'database will be created in your application folder.
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\NewDB.mdb")
MessageBox.Show("Database Created.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
All that I figured out here was that it creates a db to the specified source, but what does the provider=microsoft.jet.oledb.4.0. do.
VB.NET:
Catch Excep As System.Runtime.InteropServices.COMException
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
cat = Nothing
End Try
I know that catch is executed if try doesnt work and it "gracefully" handles the error, but I am not sure in detail. COuld someone explain this line
Catch Excep As System.Runtime.InteropServices.COMException
Sorry if I asked to many questions