SQL CE

M

merco

hi i'm trying to connect to a local PDA database , view
http://tinypic.com/hwi8ua.jpg

i've tried 1000 different connection strings
Persist Security Info=false;User ID=sa;Initial
Catalog=\programmi\dati\Sycomm97_sto_ottobre.sdf;Data Source=localhost

but i get always an exception ...
i also tried with Integrated Security=SSPI
and different data source name ((local), localhost, the right ip
address) )
and different "initial catalog" names

I can't connect... (but ican connect to other SQL server in my network
!)

how can i set the right connection string ?

thank you
 
M

merco

Dim SqlC As New System.Data.SqlClient.SqlConnection
Dim Ct As New System.Data.SqlClient.SqlCommand
Dim I As Long
SqlC.ConnectionString = "Persist Security Info=false;User
ID=sa;Initial Catalog=Sycomm97_sto_ottobre;Data Source=localhost"
Try
SqlC.Open()
Catch er As System.Data.SqlClient.SqlException
For I = 0 To er.Errors.Count - 1
MsgBox(er.Errors(I).Message)
Next


End Try
Ct.CommandText = "Insert Into Cpt (codice,descrizione)
Values(2,'a')"
Ct.Connection = SqlC
Ct.ExecuteNonQuery()

MsgBox(SqlC.ConnectionString)
SqlC.Close()
 
I

Ilya Tumanov [MS]

SqlClient is for connection to SQL Server 2000/2005 which only runs on a
Windows server.

Only SQL Mobile/CE runs on device. Classes in System.Data.SqlServerCe
namespace should be used to connect to it, not SQL Client.



Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
S

Sachin Palewar

Merco,

Your connect string is all wrong.

1. You should use System.Data.SqlServerCe.SqlCeConnection instead of
sqlconnection
2. No need to use initial catalog
3. Data source is wrong, you should use path of SDF file as datasource
instead. DataSource=sdfpath

So correct code can be:

Dim SqlC As New System.Data.SqlServerCe.SqlCeConnection

SqlC.ConnectionString = "Data Source=SDF PATH;password=PASSWORD"

No need for password too, if you have not set a password for the
database.

Try this piece of code and let me know if you still have issues.

Regards,

Sachin Palewar

Palewar Techno Solutions
Pocket PC & Mobile Software Development
Nagpur, India

www.palewar.com
 
M

merco

ok, that works.

with SqlCeConnection
and Data Source=MY SDF PATH

thank you...
But ADO i think it was better ... only one kind of Db access for all...
don't you ?
 
I

Ilya Tumanov [MS]

I think you're a bit confused by ADO.Net architecture. It is in fact DB
independent, you can connect any DB you like via respective adapter.

SQLClient (connects to SQL 2000/2005 which runs on a back end server) and
SqlServerCE (connects to SQL Server CE/Mobile which runs on device) adapters
are provided by Microsoft.

Other providers (for MySql, Oracle, DB2 and so on) are available from 3rd
parries.


Best regards,


Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
M

merco

yes of cource, but with ADO i write the same code for different db...
Here i have to choose the right adapter (different class) ...
 
I

Ilya Tumanov [MS]

That seems to be the case, but in fact you just have "adapters" on a
different level.

That would be OLEDB or ODBC, for example. Your application talks to, say,
OLEDB provider which knows how to talk to the DB.

System.Data.OleDb and System.Data.Odbc providers are available on desktop so
you could talk to any OLEDB/ODBC database using the same code just like you
used to.

Of course, you'll loose all DB specific features and probably will see some
performance hit. Using specific provider is always better.

Think of it as a monkey wrench vs. wrench set. If universal wrench is so
good, why do we have wrench sets?

By the way, all providers are using same base classes and same interfaces,
so you can have the same code even with different providers.


Best regards,


Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top