Connectionstring not connecting in Visual Studios

134 Views Asked by At

I recently started working with Visual Studios and to get some practice with its conventions, I'm trying to design a simple application that connects to a database file - in this case, just the Northwind.accdb sample that came along Microsoft Access - and transfers some selected information to an XML file.

I have the bulwark of the code written out to perform the task, but whenever I try to execute it, the program throws some exception that reads, "Could not find installable ISAM." I researched this error for quite a while, and after downloading the MS Access redistributable to no avail, I'm almost sure the problem lies with my connection string:

 strDataPath = My.Computer.FileSystem.GetParentPath("Northwind.accdb")
 strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
        "Driver={Microsoft Access Driver (*.mdb, *.accdb)}; Data Source=" + strDataPath + ";Persist Security Info=False;" 

I've tried writing this out maybe a dozen different ways with all sorts of different attributes, but no matter what I try I always end up with the same error message(even though it compiles just fine). What syntax do I need to get this connection string working? Or could there be another source of error somewher ein my code?

1

There are 1 best solutions below

0
On

Try this:

strConnection = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + strDataPath + ";Persist Security Info=False;"

The Driver portion of your connection string is used in ODBC connection strings. Don't need it in OleDB connection strings.