Question error finding database specified in code

jamie

New member
Joined
Mar 22, 2010
Messages
2
Location
Ontario Canada
Programming Experience
Beginner
Frustrated rookie.......

Attempting to set up/access an Access database from VB:

m_cnADONetConnection.ConnectionString _
= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Football\FootballStats2009.mdb"

m_cnADONetConnection.Open()

I get an error indicating that it can't find the file (but it's there!!!!), and then the 2nd line is highlighted (the Open connection).

Any help would be appreciated............thanks
 
If the error message says that it can't find the file then I tend to believe it. The path you have there is somewhere that you should NEVER be saving a file anyway. Under 'C:\Documents and Settings' there should be a folder for each user and a folder for all users, so you should at least be under one of those.

Also, you can't hard-code a path like that. Vista and Win7 have no 'Documents and Settings' folder so your app simply won't work on those OSes.

What you should be doing is either storing the database file in the same folder as your app or, better still, in the Application Data folder. You can then get those paths in code no matter where they are, with no need for hard-coding.
 
thanks - am using a book that suggests that coding for ADO, exact same coding in an example that worked (in a temp directory).

I'll try moving it and see what happens

again, thanks


jamie
 
Back
Top