Sunday, March 25, 2012
cannot drop mdf file
I cannot drop a mdf file that don't have a database but is in data
directory,.
Can you help-me ?
I'am using sql server 2005.
TIA
Yeah!!!
shift+delete is the solution.
Please ignore this!!!
"Roger" <roger@.rnospam.com> escreveu na mensagem
news:%23lOqzGHLIHA.4684@.TK2MSFTNGP06.phx.gbl...
> Hi All,
>
> I cannot drop a mdf file that don't have a database but is in data
> directory,.
> Can you help-me ?
> I'am using sql server 2005.
> TIA
>
>
|||Shift + Delete would just delete the file without any warning\confirmation.
That's only the difference between Delete and Shift + Delete.
File must be using by another process somehow when you were trying to delete
the file and when you tried the Delete with Shift it was not being used so
it was deleted I believe.
Ekrem nsoy
"Roger" <roger@.rnospam.com> wrote in message
news:%23dkmWQHLIHA.1188@.TK2MSFTNGP04.phx.gbl...
> Yeah!!!
> shift+delete is the solution.
> Please ignore this!!!
>
> "Roger" <roger@.rnospam.com> escreveu na mensagem
> news:%23lOqzGHLIHA.4684@.TK2MSFTNGP06.phx.gbl...
>
|||Actually, the biggest difference between delete and shift+delete is that
shift+delete
doesn't send files to the recycle bin.
"Ekrem ?nsoy" wrote:
> Shift + Delete would just delete the file without any warning\confirmation.
> That's only the difference between Delete and Shift + Delete.
> File must be using by another process somehow when you were trying to delete
> the file and when you tried the Delete with Shift it was not being used so
> it was deleted I believe.
> --
> Ekrem ?nsoy
>
> "Roger" <roger@.rnospam.com> wrote in message
> news:%23dkmWQHLIHA.1188@.TK2MSFTNGP04.phx.gbl...
>
cannot drop mdf file
I cannot drop a mdf file that don't have a database but is in data
directory,.
Can you help-me ?
I'am using sql server 2005.
TIAYeah!!!
shift+delete is the solution.
Please ignore this!!!
"Roger" <roger@.rnospam.com> escreveu na mensagem
news:%23lOqzGHLIHA.4684@.TK2MSFTNGP06.phx.gbl...
> Hi All,
>
> I cannot drop a mdf file that don't have a database but is in data
> directory,.
> Can you help-me ?
> I'am using sql server 2005.
> TIA
>
>|||Shift + Delete would just delete the file without any warning\confirmation.
That's only the difference between Delete and Shift + Delete.
File must be using by another process somehow when you were trying to delete
the file and when you tried the Delete with Shift it was not being used so
it was deleted I believe.
--
Ekrem Önsoy
"Roger" <roger@.rnospam.com> wrote in message
news:%23dkmWQHLIHA.1188@.TK2MSFTNGP04.phx.gbl...
> Yeah!!!
> shift+delete is the solution.
> Please ignore this!!!
>
> "Roger" <roger@.rnospam.com> escreveu na mensagem
> news:%23lOqzGHLIHA.4684@.TK2MSFTNGP06.phx.gbl...
>> Hi All,
>>
>> I cannot drop a mdf file that don't have a database but is in data
>> directory,.
>> Can you help-me ?
>> I'am using sql server 2005.
>> TIA
>>
>|||Actually, the biggest difference between delete and shift+delete is that
shift+delete
doesn't send files to the recycle bin.
"Ekrem Ã?nsoy" wrote:
> Shift + Delete would just delete the file without any warning\confirmation.
> That's only the difference between Delete and Shift + Delete.
> File must be using by another process somehow when you were trying to delete
> the file and when you tried the Delete with Shift it was not being used so
> it was deleted I believe.
> --
> Ekrem Ã?nsoy
>
> "Roger" <roger@.rnospam.com> wrote in message
> news:%23dkmWQHLIHA.1188@.TK2MSFTNGP04.phx.gbl...
> > Yeah!!!
> >
> > shift+delete is the solution.
> >
> > Please ignore this!!!
> >
> >
> > "Roger" <roger@.rnospam.com> escreveu na mensagem
> > news:%23lOqzGHLIHA.4684@.TK2MSFTNGP06.phx.gbl...
> >> Hi All,
> >>
> >>
> >> I cannot drop a mdf file that don't have a database but is in data
> >> directory,.
> >>
> >> Can you help-me ?
> >> I'am using sql server 2005.
> >>
> >> TIA
> >>
> >>
> >>
> >
> >
>
cannot drop mdf file
I cannot drop a mdf file that don't have a database but is in data
directory,.
Can you help-me ?
I'am using sql server 2005.
TIAYeah!!!
shift+delete is the solution.
Please ignore this!!!
"Roger" <roger@.rnospam.com> escreveu na mensagem
news:%23lOqzGHLIHA.4684@.TK2MSFTNGP06.phx.gbl...
> Hi All,
>
> I cannot drop a mdf file that don't have a database but is in data
> directory,.
> Can you help-me ?
> I'am using sql server 2005.
> TIA
>
>|||Shift + Delete would just delete the file without any warning\confirmation.
That's only the difference between Delete and Shift + Delete.
File must be using by another process somehow when you were trying to delete
the file and when you tried the Delete with Shift it was not being used so
it was deleted I believe.
Ekrem nsoy
"Roger" <roger@.rnospam.com> wrote in message
news:%23dkmWQHLIHA.1188@.TK2MSFTNGP04.phx.gbl...
> Yeah!!!
> shift+delete is the solution.
> Please ignore this!!!
>
> "Roger" <roger@.rnospam.com> escreveu na mensagem
> news:%23lOqzGHLIHA.4684@.TK2MSFTNGP06.phx.gbl...
>|||Actually, the biggest difference between delete and shift+delete is that
shift+delete
doesn't send files to the recycle bin.
"Ekrem ?nsoy" wrote:
> Shift + Delete would just delete the file without any warning\confirmation
.
> That's only the difference between Delete and Shift + Delete.
> File must be using by another process somehow when you were trying to dele
te
> the file and when you tried the Delete with Shift it was not being used so
> it was deleted I believe.
> --
> Ekrem ?nsoy
>
> "Roger" <roger@.rnospam.com> wrote in message
> news:%23dkmWQHLIHA.1188@.TK2MSFTNGP04.phx.gbl...
>
Monday, March 19, 2012
cannot create new sql express database
Hi,
I am trying to create a new Sql Express Database (.mdf file) from inside Visual Studio 2005. I did the following:
1) Created a Database Project in Visual Studio.
2) Choose Data Source to be Microsoft SQL Server Database File
3) Browse to a directory and enter a file name for the new database, say abc.mdf
4) When I click OK, Visual Studio prompts me if I want to create the database file, I click yes.
5) After a while, I get this error message:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Then I opened SQL Server Configuration Manager, and I enabled Named Pipes and TCP/IP for both SQLEXPRESS and MSSQLSERVER. It prompts me that the settings will not change until the service is re-started.
When I go to Administrative Tools -> Services, I see that SQLServer (MSSQLSERVER) is started, and SQL Server (SQLEXPRESS) is stopped. I can stop the MSSQLSERVER service. But when I tried to start SQLEXPRESS service, I get the following error message:
Windows could not start the SQL Server (SQLEXPRESS) on Local Computer. For more information, review the System Event Lo9g. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 17058.
I have Visual Stuio 2005 and Sql Server 2005 Installed on my machine, and I believe I am logged on using an administrator account.
Can someone help me to figure out what's wrong please?
Thanks and regards,
Alice
It seems that something is wrong with your SQL Express isntallation if it won't start. You should check the error log to see if it give more details about the problem starting the service. The error log is generally located at C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG (Your InstanceID may be different).
When you check the error log, please also verify that you are not running a beta version of SQL Express. The version number should contain either 9.00.1399 or 9.00.2047.
Mike
|||Hi,
It turns out SQL Express wasn't installed properly. I re-installed it and it works fine now. Thanks a lot.
Alice
Thursday, March 8, 2012
Cannot Create .mdf Database...
Hi,
I am just starting to use VS2005 and SQL Server Express 2005. One of the tutorials I've been looking at asks me to add a new Database Item by right clicking on my project and choosing Add Item, then SQL Database.
If I try and do this I get the following error:
Failed to generate a user instanceof SQL Server due to a failure in starting the process for the user instance. The Connection will be closed.
I have searched and found there is a similar problem down to trying to do this remotely, I have carried out their suggestions of changing the built in account to "Local System" in the SQL Server Express 2005 Properties. And also delete the folder SQL SERVER in the Microsoft folder in Application Data. But this hasn't worked and I still get the error.
If I try and create a new database in the Server explorer by right clicking and selecting "Create New SQL Server Database..." This works fine.
First of all, can anyone give me any suggestions to solve my problem? And secondly, can anyone tell me why I would use an .mdf file as opposed to creating a new SQL Server Database?
Thanks in advance...
JohnnyC
hi JohnnyC,
try having a look at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=152338&SiteID=1 to see if helps..
regards
Cannot copy the mdf file after processing
I have a windows service that connects to a regular sql server 2005 database and basically bulk copies data into a SQL express database. Afterwards, I just want to copy the MDF file into a different directory. I keep getting the "Process cannot access file because it is being used by another process" error. I've tried changing the connection strings but nothing seems to work. I'm closing the connections in the code as well. Here is the code. Any thoughts or help would be appreciated. RefreshDB calls Sync 3 times and if all three calls are successful, it attempts to copy the database file to the specified location. This is where I get the error.
Public Function RefreshDB() As Boolean
Dim success As Boolean = True
Dim tables() As String = {"Job", "Equipment", "PMScheduled"}
For Each tableName As String In tables
If SyncTable(tableName) = False Then
success = False
Exit For
End If
Next
If success Then
'copy the new database to the target directory
Try
File.Copy(My.Settings.DBFilePath, My.Settings.TargetDirectory + "\EMField.mdf")
Catch ex As Exception
My.Application.Log.WriteEntry(ex.Message + "(RefreshDB)", TraceEventType.Critical)
Return False
End Try
End If
Return success
End Function
Private Function SyncTable(ByVal tableName As String) As Boolean
Dim reader As SqlDataReader
Dim sourceViewName As String = String.Format("EMField{0}View", tableName)
Dim connectionString As String = My.Settings.EMFieldConnectionString
'insert the path to the database into the connectionstring
connectionString = connectionString.Replace("[DBFilePath]", My.Settings.DBFilePath)
Try
'clear the target table first
Using targetConnection As New SqlConnection(connectionString)
Using truncateCommand As New SqlCommand(String.Format("TRUNCATE TABLE {0}", tableName), targetConnection)
targetConnection.Open()
truncateCommand.ExecuteNonQuery()
targetConnection.Close()
End Using
End Using
'create a datareader from the source database
Using sourceConnection As New SqlConnection(My.Settings.EMLiteConnectionString)
Using readCommand As New SqlCommand(String.Format("SELECT * FROM {0}", sourceViewName), sourceConnection)
sourceConnection.Open()
reader = readCommand.ExecuteReader
BulkCopy(tableName, reader, connectionString)
reader.Close()
sourceConnection.Close()
End Using
End Using
Return True
Catch ex As SqlException
My.Application.Log.WriteEntry(ex.Message + "(sync)", TraceEventType.Critical)
Return False
End Try
End Function
Public Sub BulkCopy(ByVal tableName As String, ByRef reader As SqlDataReader, ByVal connectionString As String)
Try
'bulk copy from source to target database
Using bulkCopy As New SqlBulkCopy(connectionString)
bulkCopy.DestinationTableName = tableName
bulkCopy.WriteToServer(reader)
bulkCopy.Close()
End Using
Catch ex As SqlException
'throw exception back to calling sub
Throw ex
End Try
End Sub
hi,
the database is probably still in use and an active connection is still referencing it, so even if the database autoclose property is set (for SQLExpress created databases), the physical file(s) is/are still locked and file system operations are not allowed..
first verify no active connection is still alive.. consider that connection pooling will keep them in the pool for about 1 minute after the connection has been disposed and released..
again, even if the autoclose property set is the default for SQLExpress instances, consider first "detaching" the database via sp_detach_db before performing file system operations...
regards
|||Thanks for your help. I can say with certainty that no other process is connected the sql express database because I am testing it on my own machine. That leaves the connection pooling, but I put pooling=false in the connection string. I have never "detached" a sql express database before. So where exactly (ie what database) do I run this sp_detach_db and are there any consequences in doing so? In other words when the service runs again, will I need to reattach the database before connecting to it?
Thanks,
Bob
|||hi Bob,
Coach24 wrote:
Thanks for your help. I can say with certainty that no other process is connected the sql express database because I am testing it on my own machine. That leaves the connection pooling, but I put pooling=false in the connection string. I have never "detached" a sql express database before. So where exactly (ie what database) do I run this sp_detach_db
sp_detach_db "unregister" the database from it's related SQL Server instance so that file system operations are allowed on the database's physical files..
and are there any consequences in doing so? In other words when the service runs again, will I need to reattach the database before connecting to it?
Thanks,
Bob
no consequences but, obviously, any connection to the unregistered database will fail until you "reattach" it via the
USE [master]GO
CREATE DATABASE [test] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.3\MSSQL\Data\test.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.3\MSSQL\Data\test_log.LDF' )
FOR ATTACH;
GO
statement... so, yes, you have to reattach the database before referencing it..
regards
|||While I'm certain your suggestion works, I ended up not needing it. As it turns out, even though I had pooling = false in the connection string, and I closed the connection in the code, the connection was still open when I attempted the File.Copy statement. I put a System.Threading.Thread.Sleep(5000) right before the File.Copy statement and that fixed the problem. Thanks again for your help.
Bob
Wednesday, March 7, 2012
cannot copy files
to find out where they are, do this:
use MyDatabase
exec sp_helpfile