0

I've just made a new SQL Database with Microsoft SQL Server Management Studio and I'm trying to connect to it through some C# code. However, I'm having some issues doing so.

I'm trying to connect to my database with the following line:

  String DBConnection = "Data Source=unknown; Database=SQLExpress\\Darkride; Language=English";

However my program can't find my database as I have no idea where my data source is. I've been trying to find it for hours now, but I'm getting nothing.

Does anyone know where I can find out my databases Data Source?

3
  • 1
    Please update your title with your specific problem meta.stackexchange.com/questions/10647/… Commented Apr 10, 2013 at 8:07
  • Your question has nothing to do with mysql (wrong tag) or the SQL management studion (wrong title). Commented Apr 10, 2013 at 8:09
  • '.\SQLEXPRESS' or 'localhost\SQLEXPRESS' or '127.0.0.1\SQLEXPRESS' Commented Apr 10, 2013 at 8:35

5 Answers 5

3

Take a look on the connection string examples here http://connectionstrings.com/sql-server-2012

Looks like it can be something like:

Server=.\SQLExpress;Database=Darkride;Trusted_Connection=True;
Sign up to request clarification or add additional context in comments.

Comments

1

you are missing Initial Catalog in the connection string:

 String DBConnection ="Data Source='localhost';Integrated Security='SSPI' Initial Catalog=Darkride;";

check here for more options.

Comments

0

Add "Data Source=127.0.0.1; Database=SQLExpress\\Darkride;Initial Catalog=YourDataBase;User Id=user;Password=pass"

You can use the SqlConnectionStringBuilder class to build your connection string.

A good site for refenrence is http://www.connectionstrings.com/

Comments

0

Have connection string format as:

String DBConnection = "Data Source=27.0.0.1;;Initial Catalog=Darkride;User ID=userIDText;Password=PasswordText";

Comments

0

Change your code to this:

Server=.\SQLExpress;Database=Darkride;Trusted_Connection=True;

And take a look on the link below

Connectionstring.com will help : Connection strings for SQL Server 2008

Best Regards

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.