|
-
Sep 13th, 2007, 03:36 AM
#1
Thread Starter
New Member
DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
Hi,
I am currently developing an application using vb.net 2005 and windows mobile 6 sdk,and sql server ce for my database.
I try to connect to the database i created using the following code: I get an identifier expected error
pointing the dot[.] .The code is this ("Data Source =".\ MyDatabase.sdf;"")
Visual Basic.Net 2005. The whole class is the following:
Dim conn As SqlCeConnection = Nothing
Try
conn = New SqlCeConnection("Data Source =".\ MyDatabase.sdf;"")
conn.Open()
Dim cmd As SqlCeCommand = conn.CreateCommand()
cmd.CommandText = "INSERT INTO Customers (Customerid], Name) Values('9', 'Smith')"
cmd.ExecuteNonQuery()
Finally
conn.Close()
End Try
-
Sep 13th, 2007, 04:03 AM
#2
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
In witch line you get the error?
..
Where are you from?
-
Sep 13th, 2007, 04:45 AM
#3
Thread Starter
New Member
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
hi, I get the error on :
It informs that the database file can't be found.
I am from Cyprus,studying in the uk
Last edited by Sgiorgos; Sep 13th, 2007 at 04:49 AM.
-
Sep 13th, 2007, 05:12 AM
#4
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
Well it's kinda obvious that you don't point to the correct location...
Gia sou file giorgo
-
Sep 13th, 2007, 06:03 AM
#5
Thread Starter
New Member
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
Geia sou pali ,
The problem is not this as i get the connection string from vb.net itself.
I have uploaded screen shots of the error i get.
-
Sep 13th, 2007, 06:28 AM
#6
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
"data source ="".\mydatabase.sdf;"""
-
Sep 13th, 2007, 06:33 AM
#7
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
if you are correct with the (")
here you write data source =".\mydatabase.sdf;"
-
Sep 13th, 2007, 07:35 AM
#8
Frenzied Member
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
Hi,
surely it should be
Try
conn = New SqlCeConnection("Data Source=\MyDatabase.sdf")
conn.Open()
or
conn = New SqlCeConnection("Data Source=\My Documents\MyDatabase.sdf")
Pete
-
Sep 13th, 2007, 09:16 AM
#9
Thread Starter
New Member
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
Unfortunately none of the solutions work .
Could somebody rewrite and test the application on his vb.net?
and email me the zip file containing the code and the sdf file.
It would be greatly appreciated . Thank you =)
-
Sep 13th, 2007, 09:21 AM
#10
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
Explain what the problem is and we will try to help you.
Check your solution in a windowsapplication also to see if you are doing it correctly.
(ela mi variesai )
-
Sep 13th, 2007, 10:09 AM
#11
Frenzied Member
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
The screenshots you posted explain EXACTLY what your problem is - missing identifier.
In which folder on the device is your database - your connection string needs to point to that folder.
Look at your connection string carefully - that is where your problem lies.
You have been given the correct solution already.
Pete
-
Sep 17th, 2007, 01:25 PM
#12
Thread Starter
New Member
Re: DataSource on windows mobile 6 (cant connect to sqlce database file [sdf])
ok, I have found the answer.
vb Code:
Dim MyConnection As SqlCeConnection
Dim datalocation As String = "\Program Files\ApplicationName\MyDatabase.sdf"
MyConnection = New SqlCeConnection("Data Source=" & datalocation)
Thank you for your help
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
|