开发者

Why cant I connect to a Sql CE database?

开发者 https://www.devze.com 2023-03-26 05:18 出处:网络
I have visual studio 2010. And sql management studio 2008. I have installed all the tools for Sql CE and I have created a new CE databa开发者_如何转开发se using visual studio (by clicking the blue \'c

I have visual studio 2010. And sql management studio 2008. I have installed all the tools for Sql CE and I have created a new CE databa开发者_如何转开发se using visual studio (by clicking the blue 'configure data source' hyperlink).

I have the following code on my .net 4.o page:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;
using System.Data.SqlServerCe;
using System.Data.SqlClient;

namespace EasyMediaServer
{
    public partial class TestCeConnection : EMSPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlCeConnection conn = new SqlCeConnection(@"Data Source=C:\Dropbox\Software Development\EMS\data\EMS.sdf");
            SqlCeCommand myCommand = new SqlCeCommand("Select * from tbl_media");
            myCommand.Connection = conn;

            conn.Open();

            SqlCeDataReader myReader =  myCommand.ExecuteReader();

            conn.Close();

        }
    }
}

But I get the following error:

Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8482. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.

What is going on? That article refers to CE 3.5...


Maybe this blog post would be useful: http://erikej.blogspot.com/2010/07/getting-started-with-sql-server-compact.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号