Showing posts with label examples. Show all posts
Showing posts with label examples. Show all posts

Friday, February 24, 2012

Connection string for SqlCeConnection

Which format is assumed for connection string for SqlCeConnection?
In help topics there are only examples like this:

... Data Source = 'SalesData.sdf'; ...

But this example is intended for SQL Server 2005 Mobile database located on desktop computer...

I need to custom data load from desktop to device and vice versa, so I did this:

string SqlMobileConnString = "Persist Security Info = False; Data Source = Mobile Device\CF Card\mBase.sdf; File Mode = 'shared read';";

SqlCeConnection SqlMobileConn;
SqlMobileConn = new SqlCeConnection(SqlMobileConnString);
SqlMobileConn.Open();

// Exception!!! Invalid path... I tried to set path like this: "Data Source = My Computer\Mobile Device\..." and old variant with slash: "Data Source = \Mobile Device\...", but nothing was helpful... It's very strange because even SQL Server Management Studio uses this format: "Data Source = Mobile Device\..."

I only know that this format is intended to use from mobile applications:
"Data Source = \CF Card\...". It's quite simple and logically ...

So I don't know what to do... Please help!

P.S. Sorry for my english :)

\ should be escaped as \\ in C#.
Or please use verbatim strings by adding @. to the string.|||

Oh, string is ok, I forgot to set @. here (in code everything was OK).

But I've solved problem with connection!

I used namespace Microsoft.SqlServerCe.Client instead of System.Data.SqlServerCe, in which I found classes identical to classes from the latter one.

Instance of Microsoft.SqlServerCe.Client.SqlCeConnection class connected to my SQL Server 2005 Mobile database on PocketPC through ActiveSync and I viewed data from it on my desktop computer.

Only one question: Where I can find some detailed info about this namespace?
It is located in

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Microsoft.SqlServerCe.Client.dll

or

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Microsoft.SqlServerCe.Client.dll

I've found no information about this namespace (as for me I've found it searching files *sqlserverce*.dll in My Computer :)

Maybe it is not documented yet...

|||Microsoft.SqlServerCe.Client.dll is not supported and hence not documented.

Thanks,
Laxmi NRO, SQL Mobile, Microsoft|||

in most instances,you have to replace SqlCommand with SqlCeCommand , XxxYxx with XxxCeYyy
(my app was for windows ce 5.0 for symbol 3000 handheld and pocket pc ).

to connect ms sql management studio to .sdf file on visual studio seems to require the non express edition of the sql management studio

|||

How can i do it in VB.NET?

Thanks

Fabio

Connection string for SqlCeConnection

Which format is assumed for connection string for SqlCeConnection?
In help topics there are only examples like this:

... Data Source = 'SalesData.sdf'; ...

But this example is intended for SQL Server 2005 Mobile database located on desktop computer...

I need to custom data load from desktop to device and vice versa, so I did this:

string SqlMobileConnString = "Persist Security Info = False; Data Source = Mobile Device\CF Card\mBase.sdf; File Mode = 'shared read';";

SqlCeConnection SqlMobileConn;
SqlMobileConn = new SqlCeConnection(SqlMobileConnString);
SqlMobileConn.Open();

// Exception!!! Invalid path... I tried to set path like this: "Data Source = My Computer\Mobile Device\..." and old variant with slash: "Data Source = \Mobile Device\...", but nothing was helpful... It's very strange because even SQL Server Management Studio uses this format: "Data Source = Mobile Device\..."

I only know that this format is intended to use from mobile applications:
"Data Source = \CF Card\...". It's quite simple and logically ...

So I don't know what to do... Please help!

P.S. Sorry for my english :)

\ should be escaped as \\ in C#.
Or please use verbatim strings by adding @. to the string.|||

Oh, string is ok, I forgot to set @. here (in code everything was OK).

But I've solved problem with connection!

I used namespace Microsoft.SqlServerCe.Client instead of System.Data.SqlServerCe, in which I found classes identical to classes from the latter one.

Instance of Microsoft.SqlServerCe.Client.SqlCeConnection class connected to my SQL Server 2005 Mobile database on PocketPC through ActiveSync and I viewed data from it on my desktop computer.

Only one question: Where I can find some detailed info about this namespace?
It is located in

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Microsoft.SqlServerCe.Client.dll

or

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Microsoft.SqlServerCe.Client.dll

I've found no information about this namespace (as for me I've found it searching files *sqlserverce*.dll in My Computer :)

Maybe it is not documented yet...

|||Microsoft.SqlServerCe.Client.dll is not supported and hence not documented.

Thanks,
Laxmi NRO, SQL Mobile, Microsoft|||

in most instances,you have to replace SqlCommand with SqlCeCommand , XxxYxx with XxxCeYyy
(my app was for windows ce 5.0 for symbol 3000 handheld and pocket pc ).

to connect ms sql management studio to .sdf file on visual studio seems to require the non express edition of the sql management studio

|||

How can i do it in VB.NET?

Thanks

Fabio

Connection string for SqlCeConnection

Which format is assumed for connection string for SqlCeConnection?
In help topics there are only examples like this:

... Data Source = 'SalesData.sdf'; ...

But this example is intended for SQL Server 2005 Mobile database located on desktop computer...

I need to custom data load from desktop to device and vice versa, so I did this:

string SqlMobileConnString = "Persist Security Info = False; Data Source = Mobile Device\CF Card\mBase.sdf; File Mode = 'shared read';";

SqlCeConnection SqlMobileConn;
SqlMobileConn = new SqlCeConnection(SqlMobileConnString);
SqlMobileConn.Open();

// Exception!!! Invalid path... I tried to set path like this: "Data Source = My Computer\Mobile Device\..." and old variant with slash: "Data Source = \Mobile Device\...", but nothing was helpful... It's very strange because even SQL Server Management Studio uses this format: "Data Source = Mobile Device\..."

I only know that this format is intended to use from mobile applications:
"Data Source = \CF Card\...". It's quite simple and logically ...

So I don't know what to do... Please help!

P.S. Sorry for my english :)

\ should be escaped as \\ in C#.
Or please use verbatim strings by adding @. to the string.|||

Oh, string is ok, I forgot to set @. here (in code everything was OK).

But I've solved problem with connection!

I used namespace Microsoft.SqlServerCe.Client instead of System.Data.SqlServerCe, in which I found classes identical to classes from the latter one.

Instance of Microsoft.SqlServerCe.Client.SqlCeConnection class connected to my SQL Server 2005 Mobile database on PocketPC through ActiveSync and I viewed data from it on my desktop computer.

Only one question: Where I can find some detailed info about this namespace?
It is located in

C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\Microsoft.SqlServerCe.Client.dll

or

C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Microsoft.SqlServerCe.Client.dll

I've found no information about this namespace (as for me I've found it searching files *sqlserverce*.dll in My Computer :)

Maybe it is not documented yet...

|||Microsoft.SqlServerCe.Client.dll is not supported and hence not documented.

Thanks,
Laxmi NRO, SQL Mobile, Microsoft|||

in most instances,you have to replace SqlCommand with SqlCeCommand , XxxYxx with XxxCeYyy
(my app was for windows ce 5.0 for symbol 3000 handheld and pocket pc ).

to connect ms sql management studio to .sdf file on visual studio seems to require the non express edition of the sql management studio

|||

How can i do it in VB.NET?

Thanks

Fabio

Tuesday, February 14, 2012

Connection string

I am connecting to a SQL Express database from Excel 2K.
I have three connection strings examples. The first two work however the
third was the one I wanted to use as I do not want to specify a local db.
These two work fine:
strConn = "PROVIDER=SQLOLEDB; DATA SOURCE=(local);INITIAL CATALOG=IPS;
Trusted_Connection=yes;"
strConn = "PROVIDER=SQLOLEDB; DATA SOURCE=(local);INITIAL CATALOG=IPS;
INTEGRATED SECURITY=sspi;"
This one doesn't which I got from http://www.connectionstrings.com/ I like
it as it is simple and easily understood.
strConn = " Server=dimension9150;Database=IPS;Truste
d_Connection=yes;"
The server name is dimension9150 as is verified in the following:
C:\>sqlcmd -S dimension9150
1> SELECT name FROM sys.databases
2> GO
name
----
--
---
master
tempdb
model
msdb
IPS
(5 rows affected)
1> exit
C:\>
Thanks in advance...Hi,
Yuu can use all of the above mentioned, the (local) can be exchanged by
the servername you want to work on like:
strConn = "PROVIDER=SQLOLEDB; DATA SOURCE=Dimension9150;INITIAL
CATALOG=IPS;
INTEGRATED SECURITY=sspi;"
(local) is only a pointer like "." or localhost to your current machine
you are connecting from. if you want to use another instance than the
default one, you have to additionally specify the instancename within
the servername, something like this: servername\instancename if you are
using a different port number than the original one,you can use
servername\instancename,Portnumber.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--

Connection string

I am connecting to a SQL Express database from Excel 2K.
I have three connection strings examples. The first two work however the
third was the one I wanted to use as I do not want to specify a local db.
These two work fine:
strConn = "PROVIDER=SQLOLEDB; DATA SOURCE=(local);INITIAL CATALOG=IPS;
Trusted_Connection=yes;"
strConn = "PROVIDER=SQLOLEDB; DATA SOURCE=(local);INITIAL CATALOG=IPS;
INTEGRATED SECURITY=sspi;"
This one doesn't which I got from http://www.connectionstrings.com/ I like
it as it is simple and easily understood.
strConn = "Server=dimension9150;Database=IPS;Trusted_Connect ion=yes;"
The server name is dimension9150 as is verified in the following:
C:\>sqlcmd -S dimension9150
1> SELECT name FROM sys.databases
2> GO
name
master
tempdb
model
msdb
IPS
(5 rows affected)
1> exit
C:\>
Thanks in advance...
Hi,
Yuu can use all of the above mentioned, the (local) can be exchanged by
the servername you want to work on like:
strConn = "PROVIDER=SQLOLEDB; DATA SOURCE=Dimension9150;INITIAL
CATALOG=IPS;
INTEGRATED SECURITY=sspi;"
(local) is only a pointer like "." or localhost to your current machine
you are connecting from. if you want to use another instance than the
default one, you have to additionally specify the instancename within
the servername, something like this: servername\instancename if you are
using a different port number than the original one,you can use
servername\instancename,Portnumber.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de