"Miro" <mironagy@golden.net> wrote in message
news:eveSHxbeGHA.3640@TK2MSFTNGP03.phx.gbl...
> Sorry forgot to post this on is forum, so this is also posted on
> microsoft.public.dotnet.langauges.vb
>
> I am teaching myself vb.net 2003, and I was wondering if someone can check
> my code.
> -It works, but i was wondering if i was on the right track or if I should
> have done it differently.
> -Again - thanks in advance to everyone who has helped me so far and
> will
> help me again.
>
> My goal last night was to create an mdb file. ( not through sql server )
> just with ado. ( i think i got that terminology right )
> -Tonights goal will be to add tables into the mdb file.
>
> Anyway, i followed the example on this link:'
>
http://www.freevbcode.com/ShowCode.asp?ID=5797 >
> and wrote my own code ( below )
>
> -Here are my questions:
> ( Keep in mind my basic goal after i teach myself vb is to be able to
> create
> a small vb.exe that will create and use
> its own database that will be installed with an install shield - basically
> a
> dummy prog so i can get the feel of a small
> dummy application from start to finish. )
>
> In the example, it says to add the Reference from the "COM" tab.
> Should I be using something from the .NET tab? What is the difference?
>
> In the Example it said to use the 2.7 ( but I selected 2.8 ) - Again it
> worked, but not sure what the difference is.
> I am thinking the answer is - no difference?
>
> Any other suggestions ?
>
> Thank You,
> Miro
>
> ============ Code Example to please check =========
>
> ' I also had to add a Reference from the "COM" tab.
> 'Microsoft ADO Ext. 2.8 for DLL and Security.
>
> ' To create the main mdb file. ( Tables will be created in another
> function )
> Function CreateRequiredDB() As Boolean
> Dim lFileExists As Boolean = False
>
> ' Without this "If statement" the Exception will catch if the file
> already exists.
> If Dir$("bla.abc") <> "" Then 'Returns the file name if it exists.
> lFileExists = True
> Else
> Dim catNewDB As New ADOX.Catalog()
> Dim sCreateString As String
> sCreateString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=bla.abc" ' & DatabaseFullPath
> Try
> 'Tries to Create the DB
> catNewDB.Create(sCreateString)
> lFileExists = True 'Created the new DB
>
> Catch e As Exception
> 'Later write a function to write this to a text error log.
> MsgBox("An Exception Occurred - " + e.Message)
>
> lFileExists = False
>
> Finally
> catNewDB = Nothing
> End Try
>
> End If
>
> Return lFileExists
> End Function
>