path not found - vs2005 to SQLCE .sdf file
Hi there,
i'm currently working on a Windows mobile 5.0 application using Vs2005.
my original intention was to store data in mobile access tables and them integrate this with data on a desktop pc.
having searched a few forums (this one included) i find i cant do that anymore so
i now want to store data in sql server ce on the pocket pc and integrate that with data in the desktop pc in SQL Server.
To SQL server Pro's i'm sure this is easy but unfortunately i'm new to both Vs2005 and
SQL so any assitance would be greatly appreciated.
i've created a .sdf database and attached this to my project (also set it as content)
but when i try to connect to the database (using either emulator or on the Pocket Pc itself) it says path not found.
I've also tried copying the .sdf file to the pocket pc and when i try and open the file using SQLCE query it says invalid database?
the code i'm using is as follows:
' declared at top of form
Imports
SystemImports
System.DataImports
System.Data.SqlTypesImports
System.Data.SqlDbTypeImports
System.Data.SqlServerCeDim dsAs DataSet =New DataSet()then on form load event
PrivateSub frmViewWalk_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load
Dim PocketConnAs SqlCeConnectionDim DataAdapterAs SqlCeDataAdapterDim strCmdAs SqlCeCommandDim strdb as String
strdb = fcnFindDatabase(
"Mlw-Pocket.sdf") ' this function successfully returns the deployed path for the .sdf filePocketConn =
New SqlCeConnection(String.Format("Data Source={0}", strdb))strCmd =New SqlCeCommand("SELECT * FROM Address2", PocketConn)DataAdapter =
New SqlCeDataAdapter()DataAdapter.SelectCommand = strCmd
PocketConn.Open()
DataAdapter.Fill(ds,
"Address2")PocketConn.Close()
dtgWalk.DataSource = ds
EndSub Is there anything i need to install manually on My pocket PC?
any help at all would be greatly appreciated - now on day 3 trying to sort this and get the feeling it's going to be something basic that i just havent declared or installed!!
[4663 byte] By [
dazjack1] at [2007-12-23]
Already read these.....
as i stated i've already tried adding the .sdf file to the project and set build action to content.
i've also already incorporated the function which searchs for the application path.
The last three days wasted were spent reading search results from "SQL Mobile" "Path Not Found" and any combination of the two you can think of. most of the results i've either tried or just couldnt decipher.
If someone could give me a checklist that would help... or is there anything i need to manually install
on my pocket PC.
is the fact that I can't open the .sdf file on my pocket pc anything to be looked into further?
Please bear in mind that i am a virgin when it comes to both SQL and Pocket PC's (our system is set up with vb6 and MS Access) so theres a good chance it'll be something simple.
The Pocket PC is pretty much still configured the same as when it came out of the box. i havent added any programs / references?
1. Use file explorer on PPC to check if database file is actually present in correct location on device.
2. Add database file to the project, set action to content and make sure to change deploy condition from “never” to something else.
3. Make sure you’re using full path to the database in your code and that path is the one database file is actually at.
Thanks for your reply,
ive checked what you've said above;
the database is added to the project and Buildaction = content - copy always
The function to find the database path is as below and i've checked it returns the correct pathname.
Imports
System.IOImports
System.ReflectionModule
modPathFinderPublic Function fcnFindDatabase(ByVal strFileName As String)'' This is the full directory and exe nameDim fullAppName As String = [Assembly].GetCallingAssembly().GetName().CodeBase' This strips off the exe nameDim fullAppPath As String = Path.GetDirectoryName(fullAppName)' This adds a file name to the pathDim fullFileName As String = Path.Combine(fullAppPath, strFileName)'fcnFindDatabase = fullFileName
'fullAppPath =
NothingfullFileName =
Nothing'End FunctionEnd
ModuleOnce the application is deployed the file is sat in the project folder on the ppc.
could it be the way i've created the Database?
it was created and stored on my desktop pc using SQL Server 2005 (shipped with vs2005) and it is a
SQLServer Mobile Edition 2005 .sdf type of database file.
the application i am using on the ppc to try and open the database manually is SQL Query analyzer but this shows error
invalid database type.
Please, please please any help you could give would be really appreciated.
ps the software i have installed is sql server2005 (as above)
Visual studio 2005 pro
SQL Server mobile edition 2005
.net framework 2 (this also installed itself on my ppc using activesync)
Active sync 4.0
Windows mobile 5.0
the application i am using on the ppc to try and open the database manually is SQL Query analyzer but this shows error invalid database type |
|
This sounds as if on the device you had SqlCE.Dev package version 2. WHat do you see in Remove Programs
Hi Alex, sorry for the delay in replying to your question.
I'v had a look at the programs list and it shows:
Microsoft .Net CF 2.0
SQL Mobile 2005
SQL CE 2.0
SQL CE 2.0 Dev
Hope this helps
Hi There,
After replying to Alex's question i went away and removed the SQL CE 2.0 Dev program.
I also found another thread which mentioned manually installing the following cab files:
NETCF V2.WCE5.ARMV4i.cab
SQLCE30.WCE5.ARMV4i.cab
SQLCE30.Rep.WCE5.ARMV4i.cab
SQLCE30.DEV.ENU.WCE5.ARMV4i.cab
SYSTEM_SE_ENU.cab
which i've done. Somewhere between the two this has now enabled me to access the database on the pocket PC using the query analyser...... Unfortunately the program is still throwing out an error on the same line:
Pocketconn.open() - SQLCE Exception - unspecified error
if anyone can help?
Cheers
These CABs are for generic Windows CE 5.0 device. You've mentioned you're working with Windows Mobile 5.0 which needs different CABs. So, which device you're actually using? It is important because with custom CE device you might hit missing dependencies in the OS image.
Next, what errors are in the error collection? Please look up SqlCeException class on MSDN if you don't know how to print them out.
Hi Ilya
Thank you for your response.
I am as you said using Windows mobile 5.0.
This in conjunction with Visual Studio 2005 Pro and SQL Server 2005 / SQL Mobile 2005
I am basically learning as i go with respect to SQL server / mobile and programming to ppc's so any assistance you could give me would certainly be appreciated.
My aim is to develop a pocket Pc program which will start with empty tables and store data which is then to be passed to a desktop pc in the same format once a week.
I am used to programming using visual basic and storing data in Microsoft Access but i believe this is not possible with regard a portable device.
So far i think i have the correct code to access the data on the device but am lacking somewhat on the actual setup of both the Pocket PC and SQL Mobile / SQLServer.
Would it be possible for you to list the software/updates i require and also if there is any specific order in which i should install them.
Having tried lots of different options i'm going to wipe the Desktop PC and reinstall everything from scratch but don't want to repeat the same mistakes i've obviously already made.
Once again your help would be truly appreciated.
Thanking you in advance
Darren