Hi,

I am using Visual Basic 2008 Express Edition and published an application, and when I run the setup, it seems to install okay but when you run the program get an error message that the .sdf file is not found. I am using a Compact SQL database.

I have looked through various section of code but don't know what to change or where. Can anyone help?

Thanks in advance,
Bill Purkins

Check that
1) SDF-file is really installed i.e. copied during installation
2) check your connection string. See Connection strings for SQL Server Compact Edition. Make sure your Data Source points to the SDF-file, which is installed by your customer (or the installer to be more precise). There may be just wrong drive letter or different path in the connection string

Check that
1) SDF-file is really installed i.e. copied during installation
2) check your connection string. See Connection strings for SQL Server Compact Edition. Make sure your Data Source points to the SDF-file, which is installed by your customer (or the installer to be more precise). There may be just wrong drive letter or different path in the connection string

Thanks for your response, I did look at the connection string and it appears to have no path specified, which to me would imply the current folder, no?
Thanks,
Bill Purkins

Yes, it should be the current folder.
I suggest doing a simple FileExists test, if possible

Dim CurrentPath As String
CurrentPath = Application.StartupPath & "\"
If My.Computer.FileSystem.FileExists(CurrentPath & "<DBname>.sdf") Then
  MessageBox.Show("Database file exists", _
    "Exists", _
    MessageBoxButtons.OK, _
    MessageBoxIcon.Information)
Else
  MessageBox.Show("Database file not found", _
    "Exists", _
    MessageBoxButtons.OK, _
    MessageBoxIcon.Warning)
End If

with the installed application.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.