Creating Acces Database & Stopping Process

morphnike

Active member
Joined
Oct 8, 2005
Messages
25
Programming Experience
1-3
Hello guys,

I have a problem here which I'm trying to solve for a couple of hours now, But I just can't find a solution for it.
The idea is the following :
First it looks on the ftp-server if there is a database called "Products.mdb". If there isn't such a database, it makes an Access Database local on the computer, and when it is created, it uploads it on the server (atleast that is what I'm trying to do.
It does all the steps accept for the uploading on the ftp-part. Dont worry, the "ftp.upload"-command works perfectly.
The error is the following : "The process cannot access the file because it is being used by another process".
What can I do to stop the process???

Here is the code :

VB.NET:
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] (ftp.Login) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]Control.CheckForIllegalCrossThreadCalls = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] blnDatabase [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Boolean[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] bestand [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] ftp.GetFileList([/SIZE][SIZE=2][COLOR=#800000]"*"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#008000]'blnDatabase = False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] bestand.StartsWith([/SIZE][SIZE=2][COLOR=#800000]"Products.mdb"[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]blnDatabase = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]For
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] blnDatabase = [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]ftp.CreateDirectory([/SIZE][SIZE=2][COLOR=#800000]"Media"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] cat [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ADOX.Catalog
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] tbl [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ADOX.Table
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] (IO.File.Exists(Application.StartupPath & [/SIZE][SIZE=2][COLOR=#800000]"\Products.mdb"[/COLOR][/SIZE][SIZE=2])) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]IO.File.Delete(Application.StartupPath & [/SIZE][SIZE=2][COLOR=#800000]"\Products.mdb"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]cat.Create([/SIZE][SIZE=2][COLOR=#800000]"Provider=Microsoft.Jet.OLEDB.4.0; Data Source="[/COLOR][/SIZE][SIZE=2] & Application.StartupPath & [/SIZE][SIZE=2][COLOR=#800000]"\Products.mdb;"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#008000]'tbl = cat.Tables
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2] tbl
.Name = [/SIZE][SIZE=2][COLOR=#800000]"Product"
[/COLOR][/SIZE][SIZE=2].Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"Id"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adInteger)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"image"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adVarWChar)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"video"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adVarWChar)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"price"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adDouble)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"product"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adVarWChar)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"description"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adVarWChar)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"category"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adVarWChar)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"promo"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adBoolean)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"orders"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adInteger)
.Keys.Append([/SIZE][SIZE=2][COLOR=#800000]"Id"[/COLOR][/SIZE][SIZE=2], ADOX.KeyTypeEnum.adKeyPrimary, [/SIZE][SIZE=2][COLOR=#800000]"Id"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With
[/COLOR][/SIZE][SIZE=2]cat.Tables.Append(tbl)
tbl = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ADOX.Table
[/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2] tbl
.Name = [/SIZE][SIZE=2][COLOR=#800000]"Category"
[/COLOR][/SIZE][SIZE=2].Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"Id"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adInteger)
.Columns.Append([/SIZE][SIZE=2][COLOR=#800000]"Category"[/COLOR][/SIZE][SIZE=2], ADOX.DataTypeEnum.adVarWChar)
.Keys.Append([/SIZE][SIZE=2][COLOR=#800000]"Id"[/COLOR][/SIZE][SIZE=2], ADOX.KeyTypeEnum.adKeyPrimary, [/SIZE][SIZE=2][COLOR=#800000]"Id"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With
[/COLOR][/SIZE][SIZE=2]cat.Tables.Append(tbl)
 
 
ftp.UploadFile(Application.StartupPath & [/SIZE][SIZE=2][COLOR=#800000]"\Products.mdb"[/COLOR][/SIZE][SIZE=2])
 
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE]

Thank you very much for helping...
 
Back
Top