SqlServer CE connection string

Discussion in 'Microsoft Dot NET Compact Framework' started by Elvandar, Oct 23, 2009.

  1. Elvandar

    Elvandar Guest

    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.
     
    Elvandar, Oct 23, 2009
    #1
    1. Advertisements

  2. 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
     
    Rüdiger Kardel, Oct 23, 2009
    #2

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CafeCat

    install sqlserver ce 2.0 server tools error

    CafeCat, Sep 7, 2003, in forum: Microsoft Dot NET Compact Framework
    Replies:
    0
    Views:
    206
    CafeCat
    Sep 7, 2003
  2. Zanna

    Connection to SqlServer

    Zanna, Jul 4, 2004, in forum: Microsoft Dot NET Compact Framework
    Replies:
    6
    Views:
    206
    Zanna
    Jul 8, 2004
  3. Wapiti

    General Network Error accessing SQLserver via wired connection?

    Wapiti, Sep 16, 2004, in forum: Microsoft Dot NET Compact Framework
    Replies:
    1
    Views:
    258
    Wapiti
    Sep 16, 2004
  4. mikeb

    SQLserver connection speed under emulator

    mikeb, Sep 25, 2004, in forum: Microsoft Dot NET Compact Framework
    Replies:
    0
    Views:
    199
    mikeb
    Sep 25, 2004
  5. Guest

    How do I setup the SqlServer / IIS to sync with my SqlServer CE

    Guest, Feb 11, 2005, in forum: Microsoft Dot NET Compact Framework
    Replies:
    1
    Views:
    346
    Guest
    Feb 11, 2005
Loading...

Share This Page