|
-
Jun 9th, 2005, 03:10 PM
#1
Thread Starter
PowerPoster
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?
-
Jun 9th, 2005, 06:16 PM
#2
Thread Starter
PowerPoster
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.
?!
-
Jun 9th, 2005, 08:36 PM
#3
Re: sql server ce problem..again
Here's how I create a DB for a PDA in 2003:
VB Code:
Try
dbPath = st1
sqlEn = New System.Data.SqlServerCe.SqlCeEngine
sqlEn.LocalConnectionString = "Data Source=" & dbPath & ";Encrypt=False"
sqlEn.CreateDatabase()
Catch sqlex As System.Data.SqlServerCe.SqlCeException
MsgBox("Database creation failed." & vbNewLine & sqlex.Message, MsgBoxStyle.Exclamation, "Issue")
CreateDB = False
Exit Function
Finally
sqlEn.Dispose()
End Try
And here's a function I am using to create a connection:
VB Code:
'Use this to form the connection in the first place.
Private Function EstablishConnection() As Boolean
dbConString = "Data Source = " & dbPath
Try
dbCon = New System.Data.SqlServerCe.SqlCeConnection(dbConString)
dbCon.Open()
EstablishConnection = True
Catch sqlex As System.Data.SqlServerCe.SqlCeException
MsgBox("DB connection failed." & vbNewLine & sqlex.Message, MsgBoxStyle.Exclamation)
EstablishConnection = False
End Try
End Function
My usual boring signature: Nothing
 
-
Jun 10th, 2005, 05:53 AM
#4
Thread Starter
PowerPoster
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?
-
Jun 10th, 2005, 12:49 PM
#5
Thread Starter
PowerPoster
Re: sql server ce problem..again
still bummed
-
Jun 13th, 2005, 03:42 PM
#6
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
 
-
Jun 24th, 2005, 01:27 PM
#7
Addicted Member
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:
Dim engine As New SqlCeEngine("Data Source = \My Documents\receiving.sdf")
engine.CreateDatabase()
Dim ssceconn As New SqlCeConnection("Data Source = \My Documents\receiving.sdf")
ssceconn.Open()
Dim sqlCreateTable As SqlCeCommand = ssceconn.CreateCommand()
sqlCreateTable.CommandText = _
"CREATE TABLE People(people_id int IDENTITY(0,1) PRIMARY KEY, f_name ntext, l_name ntext)"
sqlCreateTable.ExecuteNonQuery()
ssceconn.Close()
dont forget the imports system.sqlserver
and the reference.
-
Jun 24th, 2005, 01:29 PM
#8
Thread Starter
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|