문제

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

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.

다른 팁

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;
....
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top