使用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();