Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jvdub22
Starting Member
5 Posts |
Posted - 2007-05-01 : 16:01:36
|
I am currently using the following code to connect to an SSE database from my VB 6 application: Dim cn As ADODB.Connection Set cn = New Connection cn.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _ "Persist Security Info=False;" & _ "AttachDBFileName=" & App.Path & "\database.mdf;Data Source=server1\sqlexpress" cn.OpenI was wondering if it is possible to attach a database located on a network computer? for example: "AttachDBFileName=\\<Computer Name>\Data\database.mdf" |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-01 : 16:16:54
|
That's not how it works. Your application doesn't connect to the mdf file. It doesn't care where that exists. SQL Server will find it for you. You just tell it which server and which database and it'll handle the rest. Check out www.connectionstrings.com for example connection strings.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
|
|
jvdub22
Starting Member
5 Posts |
Posted - 2007-05-01 : 16:46:27
|
so if my db is on the local machine named 'Test' on a dir called 'c:\data' and the server name is sqlexpress, with my app running on a network computer I would use the following: "AttachDBFileName=c:\data\database.mdf;Data Source=Test\sqlexpress" ? Also if im using built in windows authentication will I be able to make the connection?Thanks.quote: Originally posted by tkizer That's not how it works. Your application doesn't connect to the mdf file. It doesn't care where that exists. SQL Server will find it for you. You just tell it which server and which database and it'll handle the rest. Check out www.connectionstrings.com for example connection strings.Tara Kizerhttp://weblogs.sqlteam.com/tarad/
|
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-05-01 : 17:52:52
|
No! You don't refer to the mdf anywhere. It doesn't matter where the database files are stored. Your application doesn't care. You simply connect to the SQL Server and a database. Did you check out any of the SQL Server example connection strings at the site I posted?Stop using AttachDBFileName. You don't need that for SQL Server.And yes it will work for windows authentication. There are examples of that too at the site I posted. It's also called Integrated Security.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
|
|
|
|
|