Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi everybody :)

I've build a c# application with database(sql express 2008 R2)
when i lunch it from shared folder it didn't work !!
the connection string contains (Application.StartupPath).

what is the wrong and how do i can lunch database application from shared folder ??

and thanks a lot for helping me :)
Posted
Comments
ZurdoDev 25-Nov-13 14:41pm    
You'll have to post relevant code.
Zoltán Zörgő 25-Nov-13 14:45pm    
What exactly is the connection string, and what is the location of the database?
obada dawara 25-Nov-13 14:49pm    
the connection string is :
@"Data Source=.\SQLEXPRESS;AttachDbFilename="+Application.StartupPath+@"\sc_db.mdf;Integrated Security=True;User Instance=True"

and the location of the mdf file is on the same folder of the exe file
Zoltán Zörgő 25-Nov-13 14:53pm    
And what exactly do you mean by "shared folder"?
obada dawara 25-Nov-13 15:01pm    
I've share the folder wich contains the database and exe files from "folder properties" on windows 7,and try to lunch the application from another laptop device over the network

1 solution

Oh. Well, that won't work. You can not attach databases to SQL Server (any edition) from a mapped share. Well, there are possibilities using UNC path (like this[^] or this[^]), but you should not, since I feel more problems behind.

If you have put this on a share, I suppose you want the application to be run from multiple clients. Well, that won't work either. It is not Access.

If you need shared access to the database, you have to install it as regular server and give access to the database over native client. This is why it is a server.

If you want simply a data store for the application instances, use SQL CE instead - and make a local copy of the database and work on that since neither this provides shared access to the file.
 
Share this answer
 
Comments
obada dawara 25-Nov-13 16:48pm    
thank you Zoltan :) .... but someone said i can use the sql express put i should use same username and password when i install the sql engine on the client device ... is that true ??
Zoltán Zörgő 25-Nov-13 17:26pm    
No.
As you have set integrated security in your connection string, passwords do not apply; and as SSIDs are stored behind the scenes, using the same logon could be applicable only if you are in a domain and you use a domain account, otherwise they would have different SSIDs.
Believe me, this is not the way to do it, even if you could make it working. A server is not a local engine, and a database is not meant for shared access on file system level, even less on a network share.
obada dawara 26-Nov-13 1:35am    
i'm very thankful for your help :)
i have just one day to finish this mission...
do you have some advices to me about changing the database from express to reqular Sql server ??
it's first time which i need to use SQL Server from two devices...
Zoltán Zörgő 26-Nov-13 3:52am    
You don't need too. SQL Express is just as good to be regular server as higher editions. Just enable TCP/IP. Look here: http://blogs.msdn.com/b/sqlexpress/archive/2005/05/05/415084.aspx. The limitations are others.
1) Install SQL Express on a server
2) Configure it to accept remote connections (see above)
3) Configure security - if you are in a domain, you can use integrated security otherwise define users. See this and this
4) Attach or create database in the installed server (make sure to have the files local to the server)
5) Configure security for the database
6) Modify connection strings
7) Enjoy :)
obada dawara 27-Nov-13 11:16am    
thanks a lot ..but i faced a lot of problems :(
how the connection strings should appear ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900