Click here to Skip to main content
15,072,391 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using SQL Server DB. The connection string is

VB
Data Source=office1\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbSQLTest.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True


On local computer it is fine. On the network computer, it gives
"Invalid Key for attachdbfilename"

I do not want to make server client application. My purpose to use Sql server DB is to run my application on 3-4 computer simultaneously. I just make shortcut from my main computer to the network computers.
The reason why I donot attach with server instance is that it is difficult for the users to attach DBs with server and then manage SSMS.
Please advise
Thanks
Furqan
Posted
Updated 25-Jan-12 1:05am
v2
Comments
Amir Mahfoozi 25-Jan-12 7:13am
   
Then why you are attaching to a file in connection string ?
Furqan Sehgal 25-Jan-12 9:39am
   
What do you suggest? Example?

1 solution

The AttachDbFilename option used to attach a database to an instance of SQL Server and is used when you distribute your database, i.e make copies of database files and put them on client machines.

When ever your application is run, an instance of SQLEXPRESS is run with the user credentials as service account and the database is loaded making the user automatically a sysadmin.

If you want a single copy of the database at a central location, then this is not a good option.

Also I did not get the point why do the users have to attach DBs on a server? It is a one time job, right?
   
Comments
Furqan Sehgal 25-Jan-12 9:41am
   
I am newbie to SQL Server. I donot really know even if the user need to attach the DB to server or not. Could you explain how it will work? What connection string I need to give for main computer and then in client computers?
Sriram Chitturi 25-Jan-12 10:41am
   
Do you have a SQL Server on a server machine?

If yes, move the dbSQLTest.mdf file to the that server and attach the database.

See the following link : http://msdn.microsoft.com/en-us/library/ms190209.aspx

Create a login in SQL Server to be used by the application. Or if you want to use to windows domain logins user CREATE LOGIN <domain\login> from WINDOWS.

Check this link : http://msdn.microsoft.com/en-us/library/ms189751.aspx

Change the connection string in the application to:

a) if using a sql server login -"DataSource=<server>;Database=<database>;User=<login>;Password=<pwd>;"

b) if you are using Windows logins

"DataSource=<server>;Database=<database>;TrustedConnection=true;"

Check http://www.connectionstrings.com for different types of connection strings.
Furqan Sehgal 25-Jan-12 11:20am
   
Thank you very much.
Can I discuss some issues over email or skype? Could you give me your email address?

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