Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi, I want to upgrade from OleDb to SqlCLient, I mean from .mdb file to .sdf file.

I have installed MS SQL Server 2008 Express Compact edition and designed my database files and created tables/fields and now gonna copy it to my application directory so my application will work with that on TARGET systems, WITHOUT having SQL Server installed on target systems...

 

Well, my old connection string as follows:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\CompanyName\ProductName\Database.mdb;Jet OLEDB:Database Password = secret"

Now, what should be my new connection string for SQL 2008?

Here I found:

http://www.connectionstrings.com/sql-server-2008#1

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

But what's server address and myUsername?

How should I specify the path to my database in my application folder?

SQL Server won't be installed on target systems, so what to do?

Please help me if you can... :(

Thanks all...

Posted

Not that I've used it much, but it looks like all you need to do is specify the Data Source (path to the file) and Password (if it is password protected). You also may need to add a reference to "System.Data.SqlServerCe". You can then access your database through a SqlServerCe.SqlCeEngine object:

 

Code:

Dim connection As New SqlServerCe.SqlCeConnection("Data Source=C:\MySqlServerCompactDb.sdf;Password=password")

Dim command As New SqlServerCe.SqlCeCommand("SELECT * FROM MyTable", connection)

connection.Open()

Dim results As SqlServerCe.SqlCeDataReader

results = command.ExecuteReader(CommandBehavior.CloseConnection)

 

 

or something like that.

 

Todd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...