Sửa lỗi an ole db error has occurred năm 2024

I am having error while connecting to SQL Server:

Sửa lỗi an ole db error has occurred năm 2024

Details in Stack Trace are:


Cannot connect to ServerName.
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (.Net SqlClient Data Provider)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=233&LinkId=20476
Server Name: ServerName Error Number: 233 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, Boolean withFailover) 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()

NOTE I have tried

  • closing, reopening Sql server Management Studio.
  • closing , reopen VS & rebuild Solution
  • killed worker process accessing database.
  • login credentials are correct.
  • able to ping server to make sure its not down.

i am trying to attach external database named ( HaseebProject.mdf) but every time i got an error " An error occurred when attaching the database(s). Click the hyperlink in the Message column for details." What'sthe error is there..?? even there is any error message in message field as shown.

Sửa lỗi an ole db error has occurred năm 2024

When i click on add button to add database there are two paths in directory for database. i have tried with both but he same error.

Sửa lỗi an ole db error has occurred năm 2024

Sửa lỗi an ole db error has occurred năm 2024

Dan Bonachea

2,4405 gold badges16 silver badges31 bronze badges

asked May 8, 2016 at 14:56

Sửa lỗi an ole db error has occurred năm 2024

0

Try running SQL Server Management Studio as administrator

answered Sep 25, 2016 at 10:15

3

All of the answers I've seen so far are possible suggestions of what could be the issue, but it doesn't necessarily help you identify the issue that's preventing you from attaching this database.

The error message you are referring to is actually pointing you to a more specific error message for your case. This more specific error message is located in the Message column of the "Attach Database" window that you've already opened (you may just need to scroll to the right of the "Databases to attach" section and click on the message to see it in its entirety.

Sửa lỗi an ole db error has occurred năm 2024

Sửa lỗi an ole db error has occurred năm 2024

Bhargav Rao

50.8k28 gold badges123 silver badges140 bronze badges

answered Aug 8, 2019 at 22:07

Sửa lỗi an ole db error has occurred năm 2024

Ryan HarrisRyan Harris

3392 silver badges9 bronze badges

3

I had this problem as well, I did right click on (.mdf and .ldf) the file then on the security tab, click on Edit.

In a new window find the users and set permission to full control. If you can't find users click on:

add button-->advanced-->Find now-->find users 

and then click on Ok. if it doesn't work you can backup from your database and restore it instead of attaching. I have done it and it works.But before restoring make sure that your DB (.mdf and .ldf) shouldn't exist in SQL server database directory before restoring (it's up to your SQL server installation path in my case -->C:\Program Files\Microsoft SQL Server\MSSQL12.SQL2014\MSSQL\DATA) otherwise you will face to an error

answered Oct 10, 2017 at 10:31

Sửa lỗi an ole db error has occurred năm 2024

Mo0rtezaMo0rteza

3306 silver badges18 bronze badges

1

  1. Navigate to the directory containing the database and open the properties for the folder.
  2. Go to the Security tab, Edit permissions, Add User.
  3. In Locations, select the location that is hosting the server.
  4. In object names, Enter NT Service\MSSQL$<Instance-Name> (e.g. NT Service\MSSQL$MSSQLSERVER).
  5. Set Permissions to full control and save.

This will give your SQL Server instance full permissions for the target directory.

answered Nov 25, 2017 at 0:42

BradBrad

1715 silver badges15 bronze badges

  1. Right-click on the MyDataBase.MDF file
  2. Select Properties -> Go to Security tab -> Select Edit -> Select Add -> Select Advanced -> Select Find Now -> Selecte User Administrator & User Everyone
  3. Set permissions to full control for both
  4. Click OK
  5. Clear MyDataBase_log.LDF file
  6. Copy MyDataBase.MDF file to this location:

    USE [master] GO CREATE DATABASE [SchoolDB] ON ( FILENAME = N'C:\SchoolDB.mdf' ) FOR ATTACH GO

    0
  7. Run SQL Server Management Studio as an administrator
  8. Attach MyDataBase.MDF file from this address:

    USE [master] GO CREATE DATABASE [SchoolDB] ON ( FILENAME = N'C:\SchoolDB.mdf' ) FOR ATTACH GO

    0

Sửa lỗi an ole db error has occurred năm 2024

answered Aug 10, 2018 at 5:23

In my case I changed the main database file names so I had to select them again using button in "Current File Path" column.

Sửa lỗi an ole db error has occurred năm 2024

answered Feb 26, 2020 at 15:31

If you already have a database with the same name, delete it before you try to attach the .mdf file. My issue was that they were named the same.

Ryan Harris mentioned looking at the error message, this helped me a lot. So look at that first, you might have a different issue.

SQL message

answered Aug 5, 2021 at 20:58

Sửa lỗi an ole db error has occurred năm 2024

I had the same issue. The problem was the disk which I was transferring the database file. So if you are copying the database file from one computer to another computer make sure the removable disk is not corrupted. Always try a second removable disk. And also don't forget to run SSMS as administrator.

answered May 3, 2018 at 16:30

Sửa lỗi an ole db error has occurred năm 2024

Elham KohestaniElham Kohestani

3,1124 gold badges21 silver badges29 bronze badges

Use this command to attache db from .mdf file

USE [master]
GO
CREATE DATABASE [SchoolDB] ON 
( FILENAME = N'C:\SchoolDB.mdf' )
FOR ATTACH
GO

answered Aug 10, 2019 at 12:49

I had the same issue. After I expanded the error message, I found that it was saying the .MDF file was compressed.

I googled the issue and found this resource that solved my issue. https://blogs.msdn.microsoft.com/sqlblog/2006/10/02/sql-server-databases-are-not-supported-on-compressed-volumes/

If your error is similar to this:

Create failed for Database 'Compressed_DB'.  (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The file "E:Compressed_DB.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5118)

Then you can right click the folder in which the .MDF file resides, click "Properties". Click "Advanced" in the General tab, and uncheck "Compress contents to save disk space"

This solved the error I was getting, so try it out and attach your .MDF again.

answered Nov 14, 2019 at 22:38

Sửa lỗi an ole db error has occurred năm 2024

defkey123defkey123

1031 silver badge10 bronze badges

1

Resolution:- Just give permission to database folder and attached mdf file then.

answered Jun 8, 2022 at 8:45

check version of the sql server software and the sql software that mdf was created. must be the same versions.