Can't Delete SQLCE Database Programmatically Because It Is Locked By Another Process

Oct 24, 2011

I am having some issues with an application written in VB.net.

As part of a routine, an sqlce database gets backed up before the routine then if an error occurred gets restored. I am using system.io methods copy and delete.

I have released all the objects (connections, commands, datareaders) asscociated with the sqlce database by disposing them if they are not nothing. I also do a GC.COLLECT however when my delete command runs, an error message says it is open by another process. The PROCEXP.exe process explorer tool says it is attached to 4 undefined processes. After a while in debug mode, these clear and I am able to delete the file. However this is not acceptable as my program cannot "wait around" until they are released! I was under the impression that object.dispose forced an immediate disposal rather than waiting for the garbage collector to clean up (if you were just to use object=nothing), but still there appears to be a finite time before these objects are released.

My question is, is there an alternative way of checking (programatically in vb) for what is holding open an sqlce database (or in fact any other file for that matter) then killing these processes?

View 1 Replies


ADVERTISEMENT

Error When Trying To Delete Record Manually In SqlCE Database Explorer

Sep 15, 2009

I've been messing around trying to get an INSERT statement to work, and because of this, it has created lots of records in my database that I dont need or want.

The problem is, when I open up the table by right clicking on it in the database explorer and selecting "Show table data", I click on the record I want to delete and the following error comes up in a message box[code]...

View 3 Replies

Second User Should Not Be Able To Process Because DoProcess Is Already Locked

Oct 12, 2010

We have a stored procedure that executes in a long time so we decided to enclose it in a thread. Before executing the long stored procedure, the procedure should be locked so that only one user can execute the thread. However, I have noticed that a user can still execute twice. Here is the code. [code] The problem is when I tested the code by opening two browsers then simultaneously process, two records are being inserted into our lock table. The second user should not be able to process because the DoProcess is already locked.

View 1 Replies

Locked Access Db - Can't Compact Or Delete Ldb

Aug 23, 2007

I have VB 2005 windows application that is reading and writing records into Access 2003 database. After I deployed application to multiple servers - the database stays locked all the time - even if nobody has it open. When I check open files through Computer Manage - it doesn't show that anybody has it open. Yet - I can't delete .ldb file, I can't repair and compact the database to replace existing database, I can't rename database to replace it with other version.

View 6 Replies

Vbscript - Delete Locked Files?

Nov 19, 2009

I want delete all files in a folder, but I get access denied as the file is locked.I use an email function before i'm trying to delete the files, the send email is a built in function of the application:fcMailer.SendMailWithAttachment Process.Company, "email", Subj, "Bo", "e:upload est.xls" i tried to set it to nothing: set fcMailer = nothing and set fcMailer.SendMailWithAttachment = nothing I'm using the below to delete the files

[code]
Const DeleteReadOnly = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("e:upload*.*"), DeleteReadOnly
[/code]

How do i remove connection holding the file or simply just delete all locked files / or not locked?

View 1 Replies

How To FileInfo Before, Delete Or SHIFT + DELETE, Process Final Delete Of File

Feb 13, 2011

How can be find out which file is going to delete when, user provides command like DELETE or SHIFT + DELETE or by programmatically gives DELETE command. Well I know about FileSystemWatcher Class, but this class doesn't provide information before delete...

View 1 Replies

The Process Cannot Access The File Because Another Process Has Locked A Portion Of The File?

Feb 1, 2012

My program writes to a .txt file (and this is the ONLY program that writes to it) in a thread (with lowest priority), but every now and then it gets an error "The process cannot access the file because another process has locked a portion of the file" when it executes this code: swLog.WriteLine(sPacket).Other program reads from the file, not write to it, why do I get this error, and how can I get around it, or what shall I do when I get this error since I can't write to the file ?

Class
clsFile
Private swLogOrig As StreamWriter

[code].....

View 5 Replies

Another SqlCe Database Insert

Sep 15, 2009

I am trying to add a new record to a table, well first it checks if there is already a duplicate record in the table, and if not it makes one. If there is a duplicate, it tells the user.[code]

View 2 Replies

'Incompatible Database Version' With SQLCE Database

Nov 20, 2010

I have a SQL CE database (SDF) that I tried to edit with Database.net v3, but it is now not opening in Visual Basic Express 2010.[code]I've installed SQL Server Compact 4.0 ENU CTP1, but it is still not working.Is there any way to revert the version back? Or anything else I can do to fix this error?

View 4 Replies

Cant Insert Data To SqlCe Database

Sep 14, 2009

I have used Access databases before so thought I'd try something different. My problem is that when I try to add a new record to one of the tables in the databasethe code runs through fine, but the data is not added into the table :S have probably missed something simple, but it's been a while since I did any projects using a database.Here's my code:

Imports System.Data.SqlServerCe
Public Class Form1
Dim con As SqlCeConnection = New SqlCeConnection("Data Source=C:UsersMattDocumentsVisual

[code].....

View 15 Replies

Iterate XML File And INSERT Data Into SQLCE Or SQL Database?

Apr 6, 2009

I'm about to pull my hair out on this guys I do not know where I'm going wrong but basically I receive a web request response formatted in XML and I need to insert that data into an SQLCE database. I have tried using LINQ queries but there are no matching ID fields to Join or Group.

View 3 Replies

Sql - Hot To Access Windows Mobile SqlCE Database From Desktop .net?

Aug 20, 2010

I want to access the Windows mobile SQLCE database from the desktop application when device is connected to my PC.

View 1 Replies

Errors With Loop - Log-in App That Has Username, Passwords & Account Type Stored In A SqlCe Database

Oct 23, 2009

Getting some errors with a loop. It's a log-in app that has username, passwords & account type stored in a SqlCe database. I would like it to sync with a larger database for updates that has not been made so i left it out but I have started to make a loop that would connect it to the larger DB and if connection failed would try a set number of times before stopping the program. I'm coding this project with Visual Studio 08 pro

Dim conndb As New SqlCeConnection("Data Source = |DataDirectory|\Mydb.sdf")
Dim x, y, z As Double
x = 1
y = x + 1
z = 5

[CODE]...

View 1 Replies

VS 2008 How To Test If Sqlite Database Is Locked

Jul 2, 2009

I am accessing an sqlite database file from my VB.NET application.Currently, I use Try... Catch when opening the connection to the database, however if the database is locked by another application, it will take 5-10 seconds to throw the exception which says that the database is locked.

So I want to know if there is a way to test if the database is locked before I try to open the connection... because the long 5-10 second pause is annoying.

View 1 Replies

Delete Tables From MDB Programmatically

Jul 7, 2009

I am rewriting an application written in VB6 in VB2008.I need to beable to Create and Delete Tables from the Database at run time.I have succefully added tables to the database but can not figure out how to delete them.I'm sure I just overlooked something but have been unable to find any info on it.

View 2 Replies

How To Programmatically Delete Row In Excel

Jul 8, 2009

I found out there are ways to Select, Insert, and Update Excel file by using OLEDB. But the limitation is that we can not delete a record.My idea is to delete row (instead of record). The question is how to programmatically delete row in excel, by id selected?I want to delete the row where id = 3. I can grab the id, but have no idea how to delete the row which contains the id 3.

View 3 Replies

Programmatically Check Process CPU Percentage

Oct 1, 2009

I'm attempting to write an app that watching for process spikes. IE: Watch every active process and log the difference between initial and max values of cpu percentage (or load) of each process. The problem is that, as far as I can tell from the MSDN, the Process class doesn't contain any property that is even remotely equal to the true load of the process. For the time being I've written the code to watch the PagedMemorySize64 property, but the values that are being spit out appear to have no relevance to load.

To be clear, I don't need the actual load percentage (though it would be handy), all I need is a property that is directly related to load to show what processes 'spike' during the execution of my program.

My code as it stands (initialProcessCheck runs first, then processCheck runs every 1.5 seconds or so until other threads doing irrelavent tasks are finished, then computeDeltas is run):

Private Sub initialProcessCheck()
'Checks the current load on all active processes and stores as initial values
For Each intPID As Integer In ActiveProcessIDs
Dim CheckProcess As Process = Process.GetProcessById(intPID)

[Code]....

View 11 Replies

User Data - SQLCE Files - One Database With Multiple User On PC

Mar 3, 2010

I'm designing a PC-based app that has a little local database. I'm using VB.NET with SQL Server Compact Edition. The user will only ever have access to one database file, because it's all about storing a user specific data. However I'm thinking of the situation where there could be multiple users that access the PC, each with their own Windows account. So ideally I'd need separate database files for each User.

I'm not sure how to implement this. I was hoping to deploy the 'empty' database as a ClickOnce deployment, but I can't see how I can have a database per user doing this. Also I'm not sure where to store the database files anyway. perhaps in MyDocuments for each user? Or perhaps I need to stick to just one database, but add a 'User' column into every table, so it can hold data for every user. I didn't want to do this though - because I wanted to keep the nice separation between the data offered by physically separate files.

View 3 Replies

Add ,delete From Datagridview Programmatically In 2005?

Nov 28, 2011

In vb.net2005 i want to add and delete records programatically from DataGridView using datasource from MSAccess 2007 , and database contains fields based on date/time and yes/no .for deleting rows i am using

Dim cmd As OleDbCommandBuilder
cmd = New OleDbCommandBuilder(da)
Dim dt As New DataTable

[code]....

both are working without date and yes/no fields ,but when these included then i am getting error,can i know how to add & delete when date included

View 1 Replies

DataGrid - Add A Delete Button Programmatically?

Nov 29, 2011

I have a Datagrid in which I want to add a Delete button programmatically. I know I can do it using its properties, but i want to actually write code for it and get it done.

With dgUserAccount
.DataSource = dsDGUserAccount.Tables("SECURITYUSER")
.Columns.Add("Delete","Delete")
End With

I already have the Datagrid populated, just I want after the qeury is run, I want to add a Delete button with its type being DataGridButtonColumn

View 1 Replies

Programmatically Delete On Graphic Shape Of Many On Form?

Jan 21, 2010

I have drawn lines and boxes on a form programmatically. How do I programmatically delete one of them? Let's say I draw a line and then a box, (using button1). How do I delete the line and not the box? Or can I?

View 6 Replies

SSIS: Programmatically Delete All Files In A Given Folder?

Nov 19, 2010

I would like do this in a script task. For example i would like to be able to do something like this:

For each file as file in strDirectory
file.delete
next file

View 3 Replies

VS 2005 Delete/remove Custom Control From A Form Programmatically?

Feb 14, 2010

I created a custom control and add it to a form programatically.

The user can add and move them all over the form.

The problem is when I want to clear the form of my user control I don't know how.

I created an array of my control called ctlCorkNotes

Say I create ctlCorkNotes(1) and now I want to delete it.

How do I do this so it is gone and would have to recreate it to show up again?

View 3 Replies

Deletecommand Would Delete All Rows But Not Completely Delete In Database

Jun 6, 2011

my deletecommand delete all my rows whenever i delete a row..but when i view it again the other rows still there and the i deleted is actually deleted.[code]

View 5 Replies

Why Does DELETE Not Delete Rows From Underlying Database Table

Feb 5, 2010

*WeightCheck is a dataset connected to a mdf SQL server file..Datagrid on form is bound to the dataset..This code executes because datagrid on form updates with the deletions..[code]

View 1 Replies

Cannot Delete File - Used By Another Process?

May 28, 2010

I am facing a problem which I believe is due to the garbage collection within .NET. I have the following conundrum where I am getting files from a folder, adding them to and array and then converting them all into one file. Once this is done I move this new file elsewhere, and need to delete the previous files.

[Code]...

View 1 Replies

Check A File Which Want To Delete Is Not More Used By Another Process?

Jan 8, 2012

how to check a file which i want to delete is not more used by another process?I have a program it creates a temp file less than 1KBthen it sends it like an attachment in the emailthen I have to delete it,but cannot do it because exception comes out that it still used by another process

Try
Dim AnEmailMessage As New MailMessage
AnEmailMessage.From = New MailAddress("bla@bla.com")

[code].....

View 6 Replies

Used The Delete Sql Method To Delete Data From A Database?

Jun 10, 2010

My apologies I have posted this in the wrong catagory It should be in VB.net, my mistake)Hi guys I posted this question at the end of another topic I started but I think it will be over looked as the origional topic was solved of the dreamincode community You must all be getting sick of my quexstions by now haha I suppose you don't learn if you dont ask.

Anyway I have used the delete sql method to delete data from a database, I want to refresh the data in the form after the record has been deleted. Do I have to close the form and then open an new instance of it? or is there another way I can refresh the data?

[Code]...

View 4 Replies

Delete A File After Process.Start Runs?

Feb 22, 2012

I'm creating a sub that will run a batch file, and then delete it when it has finished.[code]...

This causes the program to immediately delete the batch file before it can run. How can I break it up so that it won't delete the batch file until after it has finished?

View 2 Replies

VS 2005 - Cannot Delete TEMP File (Being Used By Another Process)

Mar 23, 2010

I am trying to create an MDB as a temp file to save some tables and query them. After creating, I can't delete it ... Even before it is actually used. The process cannot access the file because it is being used by another process.

Dim mdbFileName As String = System.IO.Path.GetTempFileName
Dim objClassType As Type = Type.GetTypeFromProgID("ADOX.Catalog")
Dim obj As Object = Activator.CreateInstance(objClassType)
obj.[GetType]().InvokeMember("Create", System.Reflection.BindingFlags.InvokeMethod, Nothing, obj, New Object() {"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdbFileName & ";"})
[Code] .....
This MDB (after all operations) is huge (+200 Mb) and needs to be deleted.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved