0

I'm currently working on a wpf application where I tried to create a database. I used data sources > add new datasource > dataset and copied the query string for its properties, but it is giving me the following exception:

enter image description here

What might be the problem? This is a local database... and when I click on the test connection button it writes "test connection succeeded"

Thanks

2 Answers 2

2

You are connecting to an SDF file. This means that you are using Sql Server Compact, not the full fledged Sql Server.

The classes to be used are named

 SqlCeConnection 
 SqlCeCommand

The one you are using (SqlConnection) cannot understand the connection string used for a Sql Server Compact

Of course you need to add the reference to the assembly and the appropriate using directives

Assembly: System.Data.SqlServerCe.dll

using System.Data.SqlServerCe;
....
Sign up to request clarification or add additional context in comments.

3 Comments

are there anymore differences i should know about?
and how can i create a full fledged sql server?
Well there are numerous differences between the two versions. If you don't need support for stored procedure and heavy multiuser interaction you coud stay with sql server compact. It is easier to deploy and install on customers machine. If you want to use a Sql Server you could start with Sql Server Express (still free) and then upscale to Sql Server (pay version). But at this point I think you need to analyze your requirements and make a full search on internet of the differences between the versions available.
1

You are using a SqlConnection rather than the SqlCeConnection that you require. SqlConnection is for connecting directly to a "real" sql server.

Take a look at the MSDN for more information.

5 Comments

are there anymore differences i should know about?
and how can i create a "real" sql server?
I have re-linked to the MSDN article (I missed it in my answer!!). Otherwise I believe that they are mostly the same.
Creating a "real" sql server is beyond a comment here! When I say real I mean an install of Microsoft SQL Server (you can download the express version for free, give it a google).
I already installed ms sql server, and I used it before when I've developed a website using visual web developer, but there it was easy to create a database

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.