SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Cannot access a file between 2 laptops
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

BradH
Starting Member

Australia
6 Posts

Posted - 08/24/2012 :  00:01:44  Show Profile  Reply with Quote
I am trying to share an mdf file between two laptops connected via an ethernet connection. The environment is: Main laptop is called "BandMJ-PC" and the "Slave" laptop is called "BRAD-LAPTOP". I want the Main laptop to be running a particular application accessing ALAMEIN.mdf while the Slave laptop is running a different application also accessing ALAMEIN.mdf on the Main laptop. Both apps are written in vb 2010 Express. So far I have introduced a login for "BandMJ-PC\Guest" in SQL Server Management Studio and given that login full access to the folder containing the data files.
My connection string is:
"Data Source=BandMJ-PC\SQLEXPRESS;AttachDbfFilename=Y:\Test Auctions\ALAMEIN.mdf;Integrated Security=True;User Instance=False"
Where "Y" is the Network drive for the Main laptop.
When I run the application on the Slave I get "An attempt to attach an auto-named database for file "Y:\Test Auctions\ALAMEIN.mdf failed. A database with the same name exists, or specified file canot be opened, or it is located on UNC share."
I have spent days trying to google a solution but there seems to be a huge amount of solutions but I've yet to find one that works for me.
Any help would be greatly appreciated.

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 08/24/2012 :  04:21:38  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
When sql server is running it locks the files - yoou can't have two versions running on the same files at the same time - and just as well otherwise you would corrupt the database.

You probably need to connect to sql server on the main laptop from the application on the slave - i.e. just have one copy of the database engine running on the main laptop providing services.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.

Edited by - nigelrivett on 08/24/2012 04:23:44
Go to Top of Page

BradH
Starting Member

Australia
6 Posts

Posted - 08/27/2012 :  01:23:53  Show Profile  Reply with Quote
Thank You Nigel for the response. With the connection string "Data Source = BandMJ\SQLEXPRESS; etc" I though I was connecting to the sql server on the main laptop. What am I missing?
Thanks again
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3328 Posts

Posted - 08/27/2012 :  04:41:02  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
That would but you are telling it to attach the file. The server needs to be already up and running and you connect to the server - actually form both laptops.

So yoou start sql server on the main laptop - yoou shoouldn't need to attach the file the database will already be there unless yoou detach it. Then you can connect from either laptop as long as the network is set up properly.

It's not like access where yoou open a file - the server is always running waiting for connections.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

BradH
Starting Member

Australia
6 Posts

Posted - 08/29/2012 :  00:18:00  Show Profile  Reply with Quote
I am probably not expressing myself well. I have the mdf file on the main laptop and I am trying to access this mdf file via a client laptop using the version of sql server that is located on the main laptop. So as I understand it, the sql server on the main laptop is in control, so I should be able to access the same mdf file from the main laptop using a different application. At this stage I can't get the application on the client laptop to connect to the mdf file on the main laptop. I have removed the firewall on the main laptop, given the client laptop full security access on the folder containing the mdf file on the main laptop.
Thanks again
Brad
Go to Top of Page

khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 08/29/2012 :  00:52:34  Show Profile  Reply with Quote
You have SQL Server Express running on the main laptop. SQL Server is unlike MS Access where you need to attach to the database file. So for both of your laptop (main and client) you don't need to attach the mdf file. Which also means, you don't need to share out the folder on the main laptop. Basically, you only need to specify the data source as hostname\instance in the connection string.

something like
Data Source=BandMJ-PC\SQLEXPRESS;Initial Catalog=myDataBase;Integrated Security=SSPI;

do refer to http://www.connectionstrings.com/ for further information



KH
Time is always against us

Go to Top of Page

BradH
Starting Member

Australia
6 Posts

Posted - 08/29/2012 :  02:46:49  Show Profile  Reply with Quote
Hello Khtan,
Thank you for replying to my query. I have tried your suggestion and changed my connection string to:
Data Source=BandMJ-PC\SQLEXPRESS;Initial Catalog=Y:\database.mdf;Integrated Security=SSPI" (Where Y is the network drive for this file with respect to the client laptop)
This now creates this error "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found....."
This is driving me bonkers.
Thanks again for your help
Brad
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000