Sunday, February 19, 2012

c# against ms sql express - multi user access

I have developed two programs that operates against the same database. One of the program is just a display program that displayes the data put into the other administation program where you put in the data to be displayed (an administration program).

Every time I access the db from the administration program, the display program stops and throws connection pool errors and other database errors. For me, it looks like it does′t do multi-access to a database.

I have tried putting user instance to off in both programs, but this didn′t help.

Connection string also points to same file database.

It sounds like you're trying to attach the same database file to two different SQL instances. Turning User Instances off isn't enough if you still have the database sitting detached in your user profile directory. You will actually need to move the file into the Data directory, attach it to the parent instance of SQL Express and then use a standard connection string from each application to point to it rather than trying to attach it on the fly in each application.

Mike

|||

Yes, you are correct on that. Two applications, one database.

Move it to the MS SQL Server′s datadir is OK. Then, I just remove the "attached-db" attribute from the connection string and only use servername=sqlexpress/localhost, correct? Or is it more I need to do?

|||

I just can′t seen to get around the file-mess. When I use the connection wizard in VS, I only get the option to attach-db file, and it will not let me continue before I have selected that. But I want to use more normal connections using server name so that I can connect to db from both programs.

I have tried to manually edit the connection string it makes: Data Source=XP1\SQLEXPRESS;Integrated Security=True;Connect Timeout=30; Then I get "Invalid object name tablename" etc. I′m using table adapter, but it doesn′t give me connection warnings, strange enough.. Is it something I need to change in tableadapter after changing the connection string in settings?

|||Never mind.. forgot the initial catalog...|||-|||

Looks like you got things going, just wanted to check back to be sure things were working.

Mike

No comments:

Post a Comment