如何通过vb.net以编程方式附加服务器实例
问题描述:
我需要将驻留在应用程序文件夹的MyData目录中的数据库附加到客户端计算机上的SQL Server实例.怎么做?
任何机构都可以为我提供vb.net代码,以便我的应用程序在首次运行时可以做到吗?
谢谢
Hi,
I need to attach my database, that resided in the MyData directory of my application folder, to the instance of SQL server on client''s machine. How to do it?
Could any body give me vb.net code for that so my application does it when run for the first time?
Thanks
答
尝试一下,这可能对您有帮助
Try this, this may helps you
Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;
看到这里了解更多...
http://connectionstrings.com/sql-server-2008 [
See here for more ...
http://connectionstrings.com/sql-server-2008[^]
Thanks
--RA
我想为此重定向您.阅读并恢复原状
http://www.daniweb.com/software-development/vbnet/threads/84306 [ ^ ]
I want to redirect you on this. Have read and revert back with your stuck
http://www.daniweb.com/software-development/vbnet/threads/84306[^]
好,您需要使用ADO.NET.请参阅:
http://en.wikipedia.org/wiki/ADO.NET [ http://msdn.microsoft.com/en-us/library/aa286484.aspx [ ^ ].
另请参阅: http://www.devlist.com/ConnectionStringsPage.aspx [为初学者使用ADO.NET [ ^ ].
祝你好运,—SA
Well, you need to use ADO.NET. Please see:
http://en.wikipedia.org/wiki/ADO.NET[^],
http://msdn.microsoft.com/en-us/library/aa286484.aspx[^].
See also: http://www.devlist.com/ConnectionStringsPage.aspx[^].
For starters, I advise this CodeProject article: Using ADO.NET for beginners[^].
Good luck,—SA