I am using 'ADOX.Catalog' namespace and the following code to create a new MS Access database.
Private Function CreateAccessDatabase() As Boolean
'-------------------------------------------------------
'This method is called to create a new Access database
'Required: NewDBConnectionString
'-------------------------------------------------------
Dim ADOXCatalog As New ADOX.Catalog
Try
If Me.NewDBConnectionString.Trim.ToString.Length = 0 Then Throw New Exception("Connection string is not specified")
'Call create method to create a new database
ADOXCatalog.Create(Me.NewDBConnectionString.Trim.T oString)
Return True
Catch ex As Exception
Throw ex
Return False
Finally
If Not ADOXCatalog Is Nothing Then
ADOXCatalog = Nothing
End If
End Try
End Function
The moment it created database, it is also leaving a .ldb file in the same directory. I don't want that .ldb file. If I tried to delete the file forcedly, it is passing an exception "The file is being used....". All the connection strings are properly closed.
Hi venu.dil, .ldb file is automatically created by the system to maintain integrity. Mean if you open a database (.dbm) file system auto creates ldb file to prevent changes from other user or system.
In simple words you can say if file is already open in one software or place you or someone else wont able to delete or make changes to that file durring that time.
But if you have your Visual Studio open then try to delete the file and it gives and error just close the project or VS itself then go to that folder where is file located physicaly.
then you should able to delete the file. Because if you open database file in VS but after change even you closed it VS still keep some of the portion available in memory.
So when you try to delete the file it gives and error. Just close VS and delete file from the folder it should work.
Thanks.
Zeeshan Faisal
http://www.zeeshanfaisal.com
Web Application Developer
Discover Communication Inc.
You need to make sure the correct permissions are set on the folder that you are creating the database in. So you need to make sure that
MODIFY permissions are granted to the user account that ASP.NET runs under. Generally, that will be the ASPNET account on Win XP Pro, or the NETWORK SERVICE account on Win 2k3. This then means that the user acount can create AND delete the ldb file.
All-Star is right if you are trying to delete the file by using application processes then you need to provide modify or delete permisions to your application so it will able to delete the file.
and before you delete a file you can also check doese your application has modify rights on the file or not. If file is in a readonly mode then remove that restriction.
After that you will able to delete the file.
Thanks.
Zeeshan Faisal
http://www.zeeshanfaisal.com
Web Application Developer
Discover Communication Inc.
also check doese your application has modify rights on the file or not
It's the folder that the permissions need to be applied to, not the file. The ldb file is only created temporarily. There's no point in applying permissions to that file at all.
venu.dil
0 Points
4 Posts
Problem with .ldb file
Oct 23, 2008 01:59 AM|LINK
I am using 'ADOX.Catalog' namespace and the following code to create a new MS Access database.
Private Function CreateAccessDatabase() As Boolean
'-------------------------------------------------------
'This method is called to create a new Access database
'Required: NewDBConnectionString
'-------------------------------------------------------
Dim ADOXCatalog As New ADOX.Catalog
Try
If Me.NewDBConnectionString.Trim.ToString.Length = 0 Then Throw New Exception("Connection string is not specified")
'Call create method to create a new database
ADOXCatalog.Create(Me.NewDBConnectionString.Trim.T oString)
Return True
Catch ex As Exception
Throw ex
Return False
Finally
If Not ADOXCatalog Is Nothing Then
ADOXCatalog = Nothing
End If
End Try
End Function
The moment it created database, it is also leaving a .ldb file in the same directory. I don't want that .ldb file. If I tried to delete the file forcedly, it is passing an exception "The file is being used....". All the connection strings are properly closed.
Can anyone help me to remove this .ldb file.
zeeca
Member
230 Points
56 Posts
Re: Problem with .ldb file
Oct 23, 2008 05:22 AM|LINK
Hi venu.dil,
.ldb file is automatically created by the system to maintain integrity. Mean if you open a database (.dbm) file system auto creates ldb file to prevent changes from other user or system.
In simple words you can say if file is already open in one software or place you or someone else wont able to delete or make changes to that file durring that time.
But if you have your Visual Studio open then try to delete the file and it gives and error just close the project or VS itself then go to that folder where is file located physicaly.
then you should able to delete the file. Because if you open database file in VS but after change even you closed it VS still keep some of the portion available in memory.
So when you try to delete the file it gives and error. Just close VS and delete file from the folder it should work.
Thanks.
http://www.zeeshanfaisal.com
Web Application Developer
Discover Communication Inc.
venu.dil
0 Points
4 Posts
Re: Problem with .ldb file
Oct 23, 2008 05:57 AM|LINK
Hi zeeca
Thanks for the reply.
During the application process I need to remove that .ldb file for some purposes. Does this one not posible?
Mikesdotnett...
All-Star
154852 Points
19855 Posts
Moderator
MVP
Re: Problem with .ldb file
Oct 23, 2008 06:31 AM|LINK
You need to make sure the correct permissions are set on the folder that you are creating the database in. So you need to make sure that MODIFY permissions are granted to the user account that ASP.NET runs under. Generally, that will be the ASPNET account on Win XP Pro, or the NETWORK SERVICE account on Win 2k3. This then means that the user acount can create AND delete the ldb file.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
zeeca
Member
230 Points
56 Posts
Re: Problem with .ldb file
Oct 23, 2008 09:30 PM|LINK
Hi There,
All-Star is right if you are trying to delete the file by using application processes then you need to provide modify or delete permisions to your application so it will able to delete the file.
and before you delete a file you can also check doese your application has modify rights on the file or not. If file is in a readonly mode then remove that restriction.
After that you will able to delete the file.
Thanks.
http://www.zeeshanfaisal.com
Web Application Developer
Discover Communication Inc.
Mikesdotnett...
All-Star
154852 Points
19855 Posts
Moderator
MVP
Re: Problem with .ldb file
Oct 24, 2008 06:18 AM|LINK
It's the folder that the permissions need to be applied to, not the file. The ldb file is only created temporarily. There's no point in applying permissions to that file at all.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
zeeca
Member
230 Points
56 Posts
Re: Problem with .ldb file
Oct 24, 2008 02:55 PM|LINK
my bad All-Star is right you need to give modify permissions for folder
http://www.zeeshanfaisal.com
Web Application Developer
Discover Communication Inc.
Mikesdotnett...
All-Star
154852 Points
19855 Posts
Moderator
MVP
Re: Problem with .ldb file
Oct 24, 2008 05:59 PM|LINK
"All Star" is the level I appear to have reached in these forums because of the points I have been awarded, not my name or anything like that.... Call me Mike [;)]
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter