Sign in to follow this  
Thevenin

Cannot connect to SQL Server, database in use?

Recommended Posts

So thus far, an IDE is turning out to be pleasant alterantive to CMD.exe, however, I cannot seem to get the database connecting. In VC#2005EE, I did this... (had it point directly to my 'Frostwinds.mdf') ... than hit ok, and got this... ... and confirmed it was MSSQL with a handle on it via process explorer... ... so, wth, why won't it share! [depressed]

Share this post


Link to post
Share on other sites
Do you have more than one instance of SQL Server running? If so, deattach it from both, and try to rerun the code. Actually, try that anyway.

You can detach a database using SQL Server Management Studio.

Share this post


Link to post
Share on other sites
How can I check if two instances are running? Everything thus far has led me to believe that only one instance is running. This was all just installed this morning, the only thing I've done is added the tables, columns, and some data. And this was done manually with the management tool, so its not possible for some script to have screwed up the config.

Share this post


Link to post
Share on other sites
If you don't want to attach the database, change the connection in your app to connect to SQL Server directly, instead of doing the "attach file" thing.

Share this post


Link to post
Share on other sites
Quote:
Original post by Arild Fines
If you don't want to attach the database, change the connection in your app to connect to SQL Server directly, instead of doing the "attach file" thing.


I know this is slightly tangential to the topic, but could you explain to me what the difference is?

I'm assuming that the 'attach file' method bypasses the need for a central database. If this is true, than this is no good for my needs because my needs include allowing an undefined number of people to read the database file simultaneously whilst one person able to write to the database.

What I'm currently doing is porting everything from MySQL over to SQL Server. So I'm completly unfamiliar with how SQL Server does things.

Share this post


Link to post
Share on other sites
I found a tutorial on how to establish a credential-less connection (via 'Windows Authentication') login with the SQL server, however, the performance is suddenly terrible!

This method does not use the dialogue box shown above, instead, it uses the normal connection string method...

public cMySQL()
{
string TheConnectionString = "Server=PETER\\SQLEXPRESS;Database=Frostwinds;Trusted_Connection=Yes;";
try
{
MySQLConnection = new SqlConnection(TheConnectionString);
MySQLConnection.Open();
}
catch (SqlException TheError)
{
MySQLConnection.Close();
throw new Exception("SQL Database Exception.\n" + TheError.Message);
}
}


In trying to find the bottleneck, I created a multithreaded application that connnected and read from it 1000 times on each of 1000 different threads, and this completed in under a second.

Any ideas what is going on here?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this