使用VS2010连接到SQL Server Compact Edition数据库-C# [英] Connecting to a SQL server compact edition database using VS2010 - c#

查看:74
本文介绍了使用VS2010连接到SQL Server Compact Edition数据库-C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是刚开始将SQL数据库与c#结合使用.我已经建立了一个数据库,但似乎无法连接到它.该数据库显示在服务器资源管理器中的数据连接下.我被告知要使用它...

Hi, I''m new to using SQL databases with c#. I have made a database but I cant seem to connect to it. The database is showing in the server explorer under data connections. I have been told to use this...

SqlConnection MyConnection = new SqlConnection("Data Source=|DataDirectory|\\db_core.sdf");

MyConnection.Open();



当我测试连接时,它会成功响应.有人可以帮忙吗?谢谢.



When I test the connect it responds successful though. Can anyone help? Thanks.

推荐答案

尝试此代码...


SqlConnection con =新的SqlConnection(数据源=.\\ sqlexpress;初始目录=数据库名称;集成安全性= True");

con.Open();
Try This Code......


SqlConnection con=new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=DatabaseName;Integrated Security=True");

con.Open();


这篇关于使用VS2010连接到SQL Server Compact Edition数据库-C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆