Showing posts with label device. Show all posts
Showing posts with label device. Show all posts

Sunday, March 25, 2012

connectivity sql ce

hi friends,

i am developing a dictionary for pocket device

i am using sql ce database .

i have included and copied that file in the project but every time exception occurs saying check the directory . file can not be found.....

may be this a little one but help me......

its urgent..........

What code are you using to open the database?|||

Public Function search(ByVal s As String)

Dim conn As SqlCeConnection = Nothing

Try

conn = New SqlCeConnection("Database='Dictionary.sdf';password='<pwd>';")

conn.Open() '<here it stops saying that file not found

Catch

Finally

conn.Close()

End Try

conn.Close()

Return 0

End Function

|||

On device, there is no relative path concept. So, please use full/absolute path!

Thanks,

Laxmi

|||

ok that part is done

using path as data source='program files/projectfolder/database'

now i have to connect a application on pda to a sql ce database on desktop

is it feasible if yes please

provide me the syntax

connectivity sql ce

hi friends,

i am developing a dictionary for pocket device

i am using sql ce database .

i have included and copied that file in the project but every time exception occurs saying check the directory . file can not be found.....

may be this a little one but help me......

its urgent..........

What code are you using to open the database?|||

Public Function search(ByVal s As String)

Dim conn As SqlCeConnection = Nothing

Try

conn = New SqlCeConnection("Database='Dictionary.sdf';password='<pwd>';")

conn.Open() '<here it stops saying that file not found

Catch

Finally

conn.Close()

End Try

conn.Close()

Return 0

End Function

|||

On device, there is no relative path concept. So, please use full/absolute path!

Thanks,

Laxmi

|||

ok that part is done

using path as data source='program files/projectfolder/database'

now i have to connect a application on pda to a sql ce database on desktop

is it feasible if yes please

provide me the syntax

Sunday, February 19, 2012

Connection string for PDA

Hello,

I am using VS 2005 and developing PDA device application to run on SQL CE. The PDA has Windows CE 5.0 OS.

Now I am using the following code for connection to database: I got this code from some website on Internet but do not remember which one:

Try
Dim FullAppName As String = [Assembly].GetCallingAssembly().GetName.CodeBase
Dim FullAppPath As String = Path.GetDirectoryName(FullAppName)
MessageBox.Show(FullAppPath)

Dim FullFileName As String = Path.Combine(FullAppPath, "Test123.sdf")
Dim cn As New SqlCeConnection(String.Format("Data Source={0}", FullFileName))
MessageBox.Show(FullFileName)
cn.Open()
MessageBox.Show("Connection Success")

Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
Here the problem is that
1. FullAppPath returns \Windows. But the database is in application folder i.e. \Program Files\DeviceSampleApp. Then why does it return \Windows.

2. So I copied the test123.sdf file in \Windows folder. But cn.Open goes to catch block. This means there is some error but surprisingly ex.ToString displays blank messagebox. What could be the issue?


3. I also changed the connection string as:
Dim cn As New SqlCeConnection("Data Source = \Program Files\DeviceSampleApp\Test123.sdf") and the Test123.sdf correctly gets deployed to this folder \Program Files\DeviceSampleApp\ which also has the EXE. Still it gives error that it cannot find the database Test123.sdf in the path \Program Files\DeviceSampleApp\ but I checked and it is there. What could be the issue?

Regards,
MI

For proper SQL CE error handling, see http://msdn2.microsoft.com/en-us/library/ms174079.aspx

For how to determine "App.Path" in .NET CF, see this: http://msdn2.microsoft.com/en-us/library/aa457089.aspx

|||

GetCallingAssembly() would work if this code is in the DLL which is called from your EXE. If this code is in the EXE itself use GetExecutingAssemly() instead.