Question

I'm currently working on a project that has a front end ASP.NET website where users will submit "orders". I then need to access a specific table in this database with another C# windows form application that interacts with multiple Serial Ports. (I'm not married to this idea, so if you think it's a better idea to have one website for both functions, i'm all ears)

Anyway, this question is regarding the ability to have two connection strings (one from ASP.NET, and the other from a local program. - Both of which will be run on the same computer)

On the C# end, i have a connection string of:

"AttachDbFilename=C:\\Users\\Jordan\\Documents\\Visual Studio 2012\\WebSites\\WebSite1\\App_Data\\MyxoData.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True;"

With this configuration, when one project is active, the other cannot access the database.

Cannot open user default database. Login failed. Login failed for user 'CMYK-164\Jordan'.

I have a feeling this is because I am using Integrated Security=true in my connection string and "User Instance=True" specifically only allows one user on a computer to log into a DB at a time...but I can't find anything that backs up my theory...or has a way around the problem.

Any suggestions would be much appreciated!

EDIT

The connection strings are not an issue. Both applications work perfectly when the other isn't active. The issue here is establishing two concurrent connections to one database, from two different C# applications.

Était-ce utile?

La solution

Building on what Rafeal's response; you need to upgrade to SQL Server Express.

SQL Server Express LocalDB is a stripped-down version with a lot of limitations; one being that it does not support concurrent connections. See the link below - the part explaining the concurrent connection limitation can be found in the last sentence of the Permissions section.

http://technet.microsoft.com/en-us/library/hh510202.aspx

You can install SQL Server Express here:

http://www.microsoft.com/en-us/server-cloud/Products/sql-server-editions/sql-server-express.aspx#fbid=xWTelsiKWFm

And in Visual Studio you can use the Database Explorer to create a Data Connection to the new database to create your tables and any stored procedures you need.

If you are not familiar with .Net and SQL Server, you can connect to the SQL Server Express database easily by using the System.Data.SqlClient namespace. Since it's designed for SQL Server products, it is supposedly more efficient than using ADO.Net or other data providers. And, at least, I have found it to be quick and easy to use. For example, since the provider is explicit, you don't need to specify a provider in the connection string, resulting in a shorter string. For more information on the connection string, see this page:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx

And you can find C# and VB examples of opening a connection at the bottom of this page:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top