From: Elvandar on
Hi all!!

I'm developing an application using VS2005 to deploy on a WM6
device...the application uses a small SqlServer CE database.

The problem is during the connection to this database: I used the
"wizard" in VS2005 to create the database and the DataSet. Then I added
a Table Adapter to create some queries, but I noticed that in the
DataSet.xsd file it puts this connection string:

<Connections>
<Connection ConnectionStringObject="Data Source
=&quot;.\MyDB.sdf&quot;" IsAppSettingsProperty="False"
Modifier="Assembly" Name="MyAppConnectionString" ParameterPrefix="@"
Provider="Microsoft.SqlServerCe.Client">
</Connection>

where the Data Source has its path and filename. The problem is that the
only way to make my app find the database is to put the absolute path to
the .sdf file ("\Program Files\MyApp\MyDB.sdf"). In all other cases it
fails...

I should put a relative path to the .sdf file because my app can be
installed both on English and Italian devices, where the Program Files
folder is named "Programmi". I already tried to put
%CSIDL_PROGRAM_FILES%\MyApp\MyDB.sdf as path, but it doesn't work...

Do you have any solution to this problem? I'd like to mantain this
structure created with the wizard, without have to create my
SqlCeConnection objects, etc...

Thanks to all for any answer!




--
"Grazie, re, per aver accettato di lasciarti vincere soltanto dai tuoi
soldati"
Veterano di fanteria ad Alessandro Magno, rive del fiume Ifasi, 326 a.C.
From: RĂ¼diger Kardel on
Am Fri, 23 Oct 2009 14:57:53 +0200 schrieb Elvandar:

> I should put a relative path to the .sdf file because my app can be
> installed both on English and Italian devices, where the Program Files
> folder is named "Programmi". I already tried to put
> %CSIDL_PROGRAM_FILES%\MyApp\MyDB.sdf as path, but it doesn't work...
>

System.Environment.GetFolderPath(Environment.SpecialFolder.Programs)
should provide you with the required folder name.

regards
Ruediger