Can not connect the database via query string (C#). The SQL Server Management Studio is showing the full path of a location instead of database name.

I can not connect to the database via C#. The database is showing full path of the database file instead of the database name. See the pic: a database showing only name 'emart' and the other database showing the full path.
: Robby

Hi,
According to your post, I know that the database name is showing file path of the database rather than the database name in SQL Server Management Studio. You were not able to
establish a connection to the database using C#.
As Olaf said, was any error message thrown out when the connection failed? How did you create these databases?
You can use the following T-SQL to attach the database and see if the issue persists.
CREATE DATABASE
databasename
    ON (FILENAME = 'filepath _Data.mdf'),
    (FILENAME = 'filepath_Log.ldf')
FOR ATTACH;
Thanks.
Tracy Cai
TechNet Community Support

Similar Messages

  • Not able to access database from a remote machine using SQL Server Management Studio

    Hi,
    I have a DB_BOX with SQL Server 2008 R2 installed. I can access the databases on the local machine using SQL Server Management Studio but it is not accessible from other machines, though the machines are in same domain.
    I have remote enabled on SQL Server box, TCP enabled, firewall off. I checked with IP Address too, all SQL Server services are running.
    The SQL Server log shows the message
    The requested service has been stopped or disabled and is unavailable at this time. The connection has been closed.
    I get the below message in SSMS from remote machine.
    Details of error message are
    ===================================
    Cannot connect to DB_BOX.
    ===================================
    A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) (.Net SqlClient Data Provider)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=64&LinkId=20476
    Server Name: DB_BOX
    Error Number: 64
    Severity: 20
    State: 0
    Program Location:
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
       at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
       at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
       at System.Data.SqlClient.TdsParserStateObject.ReadByte()
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
       at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

    Sorry, missed the message from the errorlog in the original post. You shouldn't have included that big .Net dump that hid the important facts. :-)
    My first Google attempt on that message (which I have never seen before) suggests that the TCP Enpoint is stopped, so try this:
    ALTER ENDPOINT [TSQL Default TCP]
    STATE=STARTED;
    Erland Sommarskog, SQL Server MVP, [email protected]
    This solves the problem. Thanks...

  • Find Connection String used by SQL Server Management Studio

    I am having problems getting my VS C# .NET application to connect to a SQL Server Database, even though I can connect to it (on the same machine) using SQL Server Management Studio.
    Is there any way I can find the connection string that SQL Server Management Studio generates when it connects?

    Hi,
    As you have Visual Studio on your machine, I think we can also use the Visual Database Tools of Visual Studio to generate the connection string.
    Please:
    1. Create a new data connection to the SQL Server database in the
    Server Explorer of Visual Studio
    2. After the connection is established, right-click on the connection name and select
    Properties. There is an item called Connection String in the
    Properties window.
    Reference:
    How to: Add New Data Connections in Server Explorer/Database Explorer 
    http://msdn.microsoft.com/en-us/library/3d1wkhas.aspx
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

  • Setting query timeout in Microsoft SQL Server Management Studio

    Hello,
    We have several power users with access to SQL Management studio.  They use it to write SQL queries.  Realize there are other ways to access the db -- but we're stuck giving them Management Studio so no working around that issue.
    My questions is how can we prevent them from locking up TempDB by writing poor SQL statements.  Goal is to make them 'time out'.  I have gone to Tools-->Options-->Query Execution--> SQL Server --> and set Execution time-out.  Tested
    this on my computer and this did NOT work.  Set it to 15 seconds.  Then, wrote a SQL statement (by clicking 'New Query') that took > 15 seconds and it ran successfully.  Does anyone know why this setting did not carry over?
    Any other thoughts on how to accomplish this would be appreciated. 
    Thanks,
    Dan

    I would have disconnected and reconnected, instead of just clicking New Query.
    "Premature optimization is the root of all evil." - Knuth
    If I provoked thought, please click the green arrow
    If I provoked Aha! please click Propose as Answer

  • Cannot connect to any database either in Azure or Sql Server Management Studio

    I'm unable to connect, this page just hangs on azure and from sql server management studio I get the following error - A Network-related or instance-specific error occurred while establishing a connection to SQL Server,

    Hello,
    Before you can connect to your SQL Database server, you must use the
    Windows Azure Platform Management Portal to configure the SQL Database firewall: on the Firewall Rules tab of the SQL database server, add the IP address of your computer into the IP address range.
    What's more,Windows Azure SQL Database does not support Windows Authentication. Please use SQL Server authentication in your connection string.
    Reference:How to: Configure the Server-Level Firewall Settings (Windows Azure SQL Database)
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • Auto Scheduled run of the Sql server management studio or a auto refreshing query

    Hi ALL ,
    This is a very different weird requirement but workaround  for one of my requirement  . Scenario is that sql server enterprise edition is installed on a vm . I create a session with the vm using the remote desktop . I have scheduled a ssis package
    on the server and it should run 4 am daily us timing but its failing . If in case a user is connected to the management studio package runs on time . So i have to disconnect from the remote desktop and its not possible for me to login at 4 am every day for
    running package.
    Requirement :  Is it possible that the sql sever management studio automatically turns on at 03:30 am and authenticates in .If that is possible my package won't fail . If this is not possible  is it possible that sql script auto refreshes every
    30 min's so what i can do i will run the auto refreshing script in the management studio once and will disconnect the remote desktop not the sql server session so my virtually my session on vm will end but vm is always on from the vcenter and there is some
    activity on the sql server management studio so even the application won't be closed after a stipulated time frame leading to running of my package on time.
    Please help

    Hi Latheesh NK ,
    Below is the error message SSIS one i extracted from the history :
    Date        3/8/2014 11:00:00 AM
    Log        Job History (SSIS package)
    Step ID        1
    Server        xyz\xyz
    Job Name        SSIS package
    Step Name        Package
    Duration        00:00:01
    Sql Severity    0
    Sql Message ID    0
    Operator Emailed    
    Operator Net sent    
    Operator Paged    
    Retries Attempted    0
    Message
    Executed as user: xyz\Administrator. Microsoft (R) SQL Server Execute Package Utility  Version 11.0.2100.60 for 32-bit  Copyright (C) Microsoft Corporation. All rights reserved.    Started:  11:00:00 AM  Error: 2014-03-08
    11:00:01.31     Code: 0xC0208449     Source: Data Flow Task 1 Source - Query [95]     Description: ADO NET Source has failed to acquire the connection {68D5B1D7-17B1-4F95-9B1D-7615425C4A07} with the
    following error message: "ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified".  End Error  Error: 2014-03-08 11:00:01.31     Code: 0xC0047017     Source:
    Data Flow Task 1 SSIS.Pipeline     Description: Source - Query failed validation and returned error code 0xC0208449.  End Error  Error: 2014-03-08 11:00:01.31     Code: 0xC004700C     Source:
    Data Flow Task 1 SSIS.Pipeline     Description: One or more component failed validation.  End Error  Error: 2014-03-08 11:00:01.31     Code: 0xC0024107     Source: Data Flow Task 1     
    Description: There were errors during task validation.  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  11:00:00 AM  Finished: 11:00:01 AM  Elapsed:  0.406 seconds.  The package execution
    failed.  The step failed.

  • SQL Server Management Studio - Configuring the environment for first time use

    Hi
    I have recently switched my local 'My Documents' folder location to a network drive that I 'make available off line' to allow on-line/off-line work and synchronisation when I am working in and out of the office.
    When I load my SQL Server Management Studio 2005 I frequently get 'Microsoft SQL Server Management Studio is configuring the environment for first time use'.
    Management Studio  them loads and I can continue without problem.
    I am guessing it is trying to make reference to some settings file. Any ideas? I wonder if I can change/move these settings elsewhere to a local drive?
    Thanks

    Hi,
    There is bug report of this issue:
    http://connect.microsoft.com/SQLServer/feedback/details/126364/configuring-enviroment-for-the-first-time-every-time-in-ms-sql-server-management-express
    "SQL Server Management Studio Express saves the settings for the user in ...\Documents and Settings\<User Profile>\Local Settings\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM
    and in ...\Documents and Settings\<user profile>\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM
    if any of these files are not available or unusable, SSMSE will generate new ones."
    Hope this helps.
    BR,
    JoukoK

  • Can't connect to MSSQL-server via SQL Server Management Studio. Noone else can utilize the server either

    Suddenly the mSSQL-server has stopped working, and the application doesn't have any connection to it.
    Also, I cant connect locally via SQL Server Management Studio.
    Any ideas on where to start?
    Have SQL Server 2008 R2

    Try DAC first:
    http://technet.microsoft.com/en-us/library/ms178068(v=sql.105).aspx
    If that fails, go to Configuration Manager and restart the server.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database"

    Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
    When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
    somewhere that there should be a compact database option. but I do not see it.
    What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
    Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
    Thank you for your help..
    diana4

    Hello,
    With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
    You can use the free SQL CE Toolbax instead; see
    http://sqlcetoolbox.codeplex.com/
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • The SQL Server Management Studio used for SQL 2012

    Hi,
    Wanted to confirm is SQL Server Management Studio 2008 compatible client for
    SQL server 2012, or does the client come packaged with the SQL 2012

    Related thread:
    http://stackoverflow.com/questions/12136005/sql-server-management-studio-2008-connects-to-sql-2012-localdb
    SQL Server 2012 client tools include SSMS 2012 version.
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • SQL 2008 R2: Microsoft SQL Server Management Studio cannot shut down because a modal dialog is active. Close the active dialog and try again

    When starting SQL Server 2008 R2 it hangs , and I cannot exit...so when  trying to logoff to reset I get the following "Microsoft SQL Server Management Studio cannot shut down because a modal dialog is active. Close the active dialog and try again"Any
    ideas?

    Big edit...
    I have 2008 R2 SP2 installed on my Windows 7 Machine which is also fully updated.  The marked answer above is clearly not the solution.
    The fix I had posted before did not work.  It appeared to work temporarily, but now I am back to the same invisible dialogue.  I have not been able to identify any pattern by which this is triggered.  I can have an entire day without this
    issue and then it appears the next.
    The invisible modal dialogue is definitely the connection dialogue.  The only way out is to hit the escape key to close it, but then I am no better off without an ability to connect to a server.  The dialogue is still invisible when I re-open it.
    However, even as I type this post, I have just gotten the dialogue to appear after restarting Management Studio, hitting escape, then clicking connect again.  That same pattern failed just minutes ago numerous times.  Again, I can't find any pattern.
    See you in the clock tower.

  • Problem to create "New Database Diagram" in Microsoft SQL Server Management Studio for SQL Server 2012 SQL Express

    Hi,
    I have installed SQL Server 2012 Express edition (name of installation media: en_sql_server_2012_express_edition_with_advanced_services_x64.exe) from MSDN and I have installed the application on my pc with Windows 7 Exterprise.
    Everything is working fine except when I am trying to create "New Database Diagram", where I recieve following error message:
    TITLE: Microsoft SQL Server Management Studio
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt. (Microsoft.VisualStudio.OLE.Interop)
    BUTTONS:
    OK
    I have tried two times to reinstall SQL Server 2012 Express and I have installed Cumulative Update #3 for SQL Server 2012 and restarted the machine, but I have still the same problem with the same error message.
    Installed the following fixes:
    1) 2012_RTM_DAC_CU3_2723749_11_0_2332_x64
    2) SQLServer2012_RTM_CU3_2723749_11_0_2332_x64
    These files was installed successful.
    How can I solve the problem?
    BR
    Jan Nilsson

    Hi Jan,
    Have you installed Visual Studio in your machine?
    The problem seems to be related to installing and uninstalling the VS 2011 RC0 program.
    The workaround involves copying the files from another PC with SQL 2008 or 2012 from one machine to another. Just replace this folder:
    C:\Program Files (x86)\Common Files\microsoft shared\MSDesigners8
    See also the following for further details:
    http://social.msdn.microsoft.com/Forums/en-GB/vstsdb/thread/d65c71f5-3887-4f2a-bbd3-e799a4ac6fdc
    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Can't Remove Datasets From SQL Server Management Studio Restore Database Dialog

    Hello,
    I am trying to restore a database in MS SQL 2008 R2 Management Studio on a Windows 2008 server.
    - I right click the Databases folder and choose Restore Databases.
    - I select the From device radio button as usual and click Add.
    - I specify a .bck file as usual and click OK.
    - When I return to the Restore Database dialog are two backup sets already in the "Select backup location to restore" part of the dialog that I unsuccessfully tried to restore earlier already there.
    - I can see the path to the backup set that I want to add in the "From device" field of the "Restore Database" dialog. The backup is not listed in "Select backup location to restore" as it should be.
    - I tried restarting the SQL Server service and I rebooted the server but the files were still there when I tried to do a restore.
    - There is no option to remove the extra datasets in the "Select backup location to restore" part of the dialog. I am hoping that if I can remove the extra datasets that this will resolve the problem. Does anyone have any idea how to remove them?
    Martin Mann

    Hello,
    My issue was a bit different then your screenshot. I was able to choose a backup dataset with no problem from the "Select backup devices" dialog as you show in the screenshot. At that time the "Restore Database" dialog box you show in the background had
    no backup files, you show filetest1, filetest2. However after clicking the "Add" to files were listed in the "Restore Database" dialog neither of which was the one that I was trying to add. The problem was that the wrong files were listed in the "Restore Database"
    dialog and I couldn't remove them.
    The problem turned out to be two issues. I resolved the problem as follows:
    It turned out that someone had compressed my server c:\ drive and I was not aware of it. Disk compression and SQL server have conflicts. As I had never compressed a drive I didn't know that Windows Explorer displays compressed files in blue letters. So the
    first step was to decompress the drive. Which did not fix the problem.
    What had caused the files to show up was that I had somehow created a backup with two data sets in it. It seems that when SQL Server creates a backup one of the first things it does is check the drive for the required space and create an empty backup file
    the size of the backup to reserve the disk space. It seems that I had created a file that contained space for a backup but no data with another back with data behind it. When I looked at the backup file size in explorer it was almost twice the size it should
    have been.
    I resolved the problem by changing the path of the default backup folder. I was able to do a restore from there. Afterwords the default backup folder worked and the files listed were no longer there.
    Sorry for the confusion and thanks for the help.
    Martin Mann

  • Using LV 8.6 to access database created in MS SQL Server Management Studio

    I am using Labview 8.6 to access a database created in MS SQL Server Mgmt Studio, using LabSQL ADO utilities. I don't have LV's add-on DB connectivity toolkit, but just the ADO utilities. Can i do it? If yes, how? I have no experience whatsoever in connecting and accessing data from a DB. An example would help.
    Thanks,

    Szi wrote:
    As for my opinion you cant access without DB connectivity toolkit.
    Nonsense.
    With LabSQL, you should first find an on-line SQL tutorial and refer to the Microsoft help files. I would recomend creating a UDL file. This is the connection string you use for the ADO Connection Open function. You might want to to get a little help from the db administrator. You'll certainly need help in getting a login and password.
    There are examples that come with LabSQL

  • How to create a database in Sql server management studio

    how to create a database in Sql server management studio

    One method is to run the SQL statement below from a SSMS query window:
    CREATE DATABASE MyDatabase;
    You can also right-click on the Databases node in SSMS Object explorer and select New Database.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

Maybe you are looking for

  • How to further restrict the task profile 'dimension' to selected dimensions

    Hi All, We have a dimension which we require users to maintain their own master data. We have used the secondary admin task profile which provides default access to the task 'dimension'. THis allows that user access to the BPC Admin console and also

  • Strange SocketException

    I'm writing a server-client software, with the client being an Applet and the server running at the webserver. As it is now it works just perfectly on most computers, actually all but one that I tried - which I find strange. Here's a snippet of what

  • Question on flipping multiple frames - maybe a hard one guys!

    Ok here is my problemo... I've created a 28 frame, gun firing flash. It is has massive amounts of details from everything included the gun blast to ejecting spent bullet casings, etc. (took me 6 hours to draw and make the graphical Tweens on this). O

  • Do Not Disconnect Doesn't turn off - itunes not finding ipod

    My ipod has been plugged in for hours and it still says do not disconnect. Also, itunes says that there is no ipod connected. How do I fix these and have itunes find my ipod.

  • BAPI_PR_CHANGE, successul message but commit does not actually update

    I am testing in SE37 BAPI_PR_CHANGE.   In the result msg  I get these messages: Purchase requisition 10013879 changed Instance 10013879 of object type PurchaseRequisition has been changed. and in the line item I get a qty update I'm expecting.  I the