Need help with 'unrecognized format error' when trying to create a database with the save file dialog

  • Thread starter Thread starter Lucky Hyena
  • Start date Start date
L

Lucky Hyena

Guest
Hey this is my code for creating a database programmatically using Visual Basic. I have attempted to edit the code so that it tries the .accdb extension instead of .mdb however it doesn't really work either. It saves the file, but when I try to open using it Database Access, I receive an error that the format is unrecognized.


ElseIf result = DialogResult.Yes Then
Using databaseFile As New SaveFileDialog
databaseFile.Filter = "Access Database File (*.mdb)|.mdb"
databaseFile.ShowDialog()
Dim writer As New IO.StreamWriter(databaseFile.FileName)
writer.Close()
End Using

Anything that I am doing wrong? How can I get around this issue? I have installed the 2010 Access Database Engine redistributable. I have also tried creating the database programmatically without using the save file dialog and instead using this code below. It works perfectly but I would rather use the save file dialog. How do I go about this? Thank you all very much :)


Dim creator As New ADOX.Catalog()
creator.Create("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\igerm\Documents\Computer Science\Computer Science Project\Visual Basic\Database Files\test.accdb")
creator = Nothing

Continue reading...
 
Back
Top