Results 1 to 8 of 8

Thread: sql server ce problem..again

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    sql server ce problem..again

    here we are yet again. I am really fed up of this.

    problem: how can i create a SQL Server CE mobile application? I cannot seem to be able to create a database or open a connection!

    in VS.NET 2003 if i add a reference to System.Data.SqlServerCE.dll and System.Data.SqlClient.dll - I write this code:

    private void CreateDatabase()
    {
    SqlCEEngine theEngine = new SqlCEEngine("Test.sdf");
    theEngine.CreateDatabase();
    }

    everytime I do this, when it tries to create an object I get a missing method exception. I tried soo many ways but i could not get away from the missing method exception. What am I doing wrong?

    Next, I tried VS2005 Beta 2 and it gives me a "missing assembly reference" exception.

    ?!?!?!?

    whats going on?

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: sql server ce problem..again

    im experimenting more with VS2005 B2. If i add it's version of SQL SERVER CE v2 I get this:

    An unhandled exception of type 'System.TypeLoadException' occurred in System.Windows.Forms.dll

    Additional information: Could not load type System.Data.SqlServerCe.SqlCeEngine from assembly System.Data.SqlServerCe, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=969DB8053D3322AC.


    ?!

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: sql server ce problem..again

    Here's how I create a DB for a PDA in 2003:

    VB Code:
    1. Try
    2.             dbPath = st1
    3.             sqlEn = New System.Data.SqlServerCe.SqlCeEngine
    4.  
    5.             sqlEn.LocalConnectionString = "Data Source=" & dbPath & ";Encrypt=False"
    6.             sqlEn.CreateDatabase()
    7.         Catch sqlex As System.Data.SqlServerCe.SqlCeException
    8.             MsgBox("Database creation failed." & vbNewLine & sqlex.Message, MsgBoxStyle.Exclamation, "Issue")
    9.             CreateDB = False
    10.             Exit Function
    11.         Finally
    12.             sqlEn.Dispose()
    13.         End Try

    And here's a function I am using to create a connection:

    VB Code:
    1. 'Use this to form the connection in the first place.
    2.     Private Function EstablishConnection() As Boolean
    3.         dbConString = "Data Source = " & dbPath
    4.         Try
    5.             dbCon = New System.Data.SqlServerCe.SqlCeConnection(dbConString)
    6.             dbCon.Open()
    7.             EstablishConnection = True
    8.         Catch sqlex As System.Data.SqlServerCe.SqlCeException
    9.             MsgBox("DB connection failed." & vbNewLine & sqlex.Message, MsgBoxStyle.Exclamation)
    10.             EstablishConnection = False
    11.         End Try
    12.     End Function
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: sql server ce problem..again

    your using a PDA, im using a smartphone (shouldnt make much difference should it?)

    my code was the same about creating the sqlserverce object instance etc...

    how did you add a reference to sqlserverce? where was this file located? What VS.NET version are you using?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: sql server ce problem..again

    still bummed

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: sql server ce problem..again

    I'm using VS 2003 Ent Arch.

    Using a smartphone should be about the same, but there may be some difference. To install SQLServerCE on a PDA is about as simple as it can get. In fact, it does it automatically during a debug session if you are using the hardware rather than the emulator. Of course, that's not actually what you asked, but is that the same process as you have for a smartphone?

    Since it is so simple on the PDA, I don't actually have an answer for your question, because I have never had to add a reference, it has always been there.

    Hmmm. Ok, I have looked at a project, and it looks like I only reference System.Data.SqlServerCE, System.Data, and System.Data.Common, though I don't know if those last two are important for this.
    My usual boring signature: Nothing

  7. #7
    Addicted Member
    Join Date
    May 2005
    Posts
    162

    Re: sql server ce problem..again

    i grabbed this off the microsoft site. i am doing the same thing over in the database programming thread.
    VB Code:
    1. Dim engine As New SqlCeEngine("Data Source = \My Documents\receiving.sdf")
    2.         engine.CreateDatabase()
    3.         Dim ssceconn As New SqlCeConnection("Data Source = \My Documents\receiving.sdf")
    4.         ssceconn.Open()
    5.         Dim sqlCreateTable As SqlCeCommand = ssceconn.CreateCommand()
    6.         sqlCreateTable.CommandText = _
    7.           "CREATE TABLE People(people_id int IDENTITY(0,1) PRIMARY KEY, f_name ntext, l_name ntext)"
    8.         sqlCreateTable.ExecuteNonQuery()
    9.         ssceconn.Close()
    dont forget the imports system.sqlserver
    and the reference.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: sql server ce problem..again

    Thanks very much but it will not work for me as the missingmethodexception always gets thrown at when making the engine object

    also found out that SQL CE 2.0 is not supported on my C500 smartphone which sucks... and means I have to use xml to store and retrieve data (long long job)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width