Create Database

bryan

Member
Joined
Jul 17, 2004
Messages
11
Programming Experience
Beginner
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.

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
 
I think it catches the errors caused but the Jet Objects, these are activeX Objects to creat the Database files (As there is no managed code to do so).

Mykre
 
Thanks for the replys, youve been a big help.

Yes it only creates the db file, I am trying to find something that tells me how to create the tables also
 
aight, that sounds easy enough, though (as you can tell i dont know sql worth crap) where in vb do i put that sql code? obviously i dont jes put it right in the vb editor (altough that'd be nice) but what object or commands are used here? i jes feel lost :( i am takeing a class on this stuff this fall though :)
 
Back
Top