none
database does not appear in sql server management studio RRS feed

  • Question

  • Hi,

    I'm new to SQL server and want to try it. To do this, i use VSC 2013 (C#, .net4.5, ADO) and i installed SQL Express 2014 on a PC Under W8.1pro. I succeeded to create and access a database with my application. My database is created with a code like:

    using ( var connection = new System.Data.SqlClient.SqlConnection(
    		"Data Source=(local); Integrated Security=true;User Instance=True;" ) )
    {
    	connection.Open();
    	using ( var command = connection.CreateCommand() )
    	{
    		command.CommandText =
    			String.Format( "CREATE DATABASE {0} ON PRIMARY (NAME={0}, FILENAME='{1}')", dataBaseName, dbFileName );
    		command.ExecuteNonQuery();
    
    		command.CommandText =
    			String.Format( "EXEC sp_detach_db '{0}', 'true'", dataBaseName );
    		command.ExecuteNonQuery();
    	}
    }
    

    My problem is to manage this database with "Microsoft SQL Server Management Studio"; i fact, i never succeeded to see my database in this tool. The .mdf file of my databae is located in a directory "C:\Users\myuseraccount\Documents\SQLServerExpDBs\". I tried to join my mdf file, but MSqlSMS refuse to display the content of all my user account directories.

    Someone can explain how to manage such DB in MSqlSMS?

    thanks in advance

    Pascal

    Tuesday, June 2, 2015 3:02 PM

Answers

  • Hello pasc059,

    >>using ( var connection = new System.Data.SqlClient.SqlConnection(Data Source=(local); Integrated Security=true;User Instance=True;" ) )

    I noticed you use the “(local)” as the sql server instance, so please check if this one is an instance of your installed SQL Express 2014.

    >>I tried to join my mdf file, but MSqlSMS refuse to display the content of all my user account directories.

    If this is a installed SQL Express instance, and it refuses to attach the generated .mdf file, for getting a professorial help, I suggest you could ask it on the sql server forum: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver, there are sql server experts will help you to check why it refuses to attach the generated .mdf file.

    Regards.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, June 4, 2015 6:12 AM
    Moderator

All replies

  • Hello Pascal,

    >> i use VSC 2013 (C#, .net4.5, ADO)

    As far as I know, the VS2013 contains a default sql server which is an express version. From your provided connection string, it targets to the (local) instance, please check if this is VS default sql server express instance, the result you got is expected.

    >> Someone can explain how to manage such DB in MSqlSMS?

    For the current .mdf file, if it is the scenario I mentioned above, you could firstly detach it from the VS sql express and attach it to your Microsoft SQL Server Management Studio, and of course, the data source name needs to be modified. Or changing the data source to target one instance in Microsoft SQL Server Management Studio: https://msdn.microsoft.com/en-US/library/ms188613.aspx.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 3, 2015 2:13 AM
    Moderator
  • Hi,

    thanks for reply Fred.

    I did not see the relation with VS. If i run the application outside VS, this is the same.

    I never attach something with VS, all is done by program.

    I verified that the version of the Server (12.0.2000,  for SQL server express 2012 (why not 2014?)) is the same in my App and in MSqlSMS. What is strange is that MSqlSMS does not display the content of my user account when i tried to Join a database (.mdf).

    Probably i don't understand something, but what???

    Other ideas?

    regards

    Wednesday, June 3, 2015 3:25 PM
  • Hello pasc059,

    >>using ( var connection = new System.Data.SqlClient.SqlConnection(Data Source=(local); Integrated Security=true;User Instance=True;" ) )

    I noticed you use the “(local)” as the sql server instance, so please check if this one is an instance of your installed SQL Express 2014.

    >>I tried to join my mdf file, but MSqlSMS refuse to display the content of all my user account directories.

    If this is a installed SQL Express instance, and it refuses to attach the generated .mdf file, for getting a professorial help, I suggest you could ask it on the sql server forum: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver, there are sql server experts will help you to check why it refuses to attach the generated .mdf file.

    Regards.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, June 4, 2015 6:12 AM
    Moderator
  • Hello Fred,

    As i saw, the sql server instance that i use, is an instance of SQL Express 2014.

    thanks for the link ,

    regards

    Pascal

    Thursday, June 4, 2015 9:31 AM