c# - Can't connect to SQL Server CE database -


i have following code, test connection:

public void test() {     sqlceconnection conn = new sqlceconnection(@"data source=/application/database.sdf;");     try     {         conn.open();         label1.text = "connection!";     }     catch (exception ee)     {         label1.text = "no connection!";     } } 

when trying connect database, application throws exception @ conn.open() saying

sqlceexception unhandled

and nothing more. exception message blank, i'm having hard time figuring out went wrong.

the database file there, , application returns true

file.exist(@"/application/database.sdf"); 

so have access file.

i'm doing wrong here, can me out this?

i'm using compact framework 2.0 on windows ce 5, , application in question existing one. i'm trying add database can load large amounts of data more easier.

what erik saying change code this:

public void test() {   sqlceconnection conn = new sqlceconnection(@"data source=/application/database.sdf;");   try   {     conn.open();     label1.text = "connection!";   }   catch (sqlceexception ee)  // <- notice use of sqlceexception read errors   {     sqlceerrorcollection errorcollection = ee.errors;      stringbuilder bld = new stringbuilder();     exception inner = ee.innerexception;      if (null != inner)      {       messagebox.show("inner exception: " + inner.tostring());     }     // enumerate errors message box.     foreach (sqlceerror err in errorcollection)      {       bld.append("\n error code: " + err.hresult.tostring("x"));        bld.append("\n message   : " + err.message);       bld.append("\n minor err.: " + err.nativeerror);       bld.append("\n source    : " + err.source);        // enumerate each numeric parameter error.       foreach (int numpar in err.numericerrorparameters)        {         if (0 != numpar) bld.append("\n num. par. : " + numpar);       }        // enumerate each string parameter error.       foreach (string errpar in err.errorparameters)        {         if (string.empty != errpar) bld.append("\n err. par. : " + errpar);       }      }     label1.text = bld.tostring();     bld.remove(0, bld.length);   } } 

the generic exception catching right can not give details of sqlceexception.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -