-10

'' I created a folder like this and it contains many databases. When I'm about to submit again the button there was an error of "Database already exist" i am saying that I'm about to delete the src folder instead of the databases. What should I do then? What code to use?

Dim testPath1 As String = Form1.Dir_folder.Text & "\DDC OS" & "\CARD DECK" & "\" & DateTime.Now.ToString("yyyyMMdd") & "\" & batchFolderName & "\Compare"
Dim testPath5 As String = Form1.Dir_folder.Text & "\DDC OS" & "\CARD DECK" & "\" & DateTime.Now.ToString("yyyyMMdd") & "\" & batchFolderName & "\Entry1"
Dim testPath2 As String = Form1.Dir_folder.Text & "\DDC OS" & "\CARD DECK" & "\" & DateTime.Now.ToString("yyyyMMdd") & "\" & batchFolderName & "\Entry2"
Dim testPath3 As String = Form1.Dir_folder.Text & "\DDC OS" & "\CARD DECK" & "\" & DateTime.Now.ToString("yyyyMMdd") & "\" & batchFolderName & "\Images"
Dim testPath4 As String = Form1.Dir_folder.Text & "\CBATCH"
Dim testPath6 As String = Form1.Dir_folder.Text & "\CBATCH" & "\CardDeck" & "\" & DateTime.Now.ToString("yyyyMMdd")

If Not IO.Directory.Exists(testPath5) Then
    MkDir(testPath5)
End If
If Not IO.Directory.Exists(testPath1) Then
    MkDir(testPath1)
End If
If Not IO.Directory.Exists(testPath2) Then
    MkDir(testPath2)
End If
If Not IO.Directory.Exists(testPath3) Then
    MkDir(testPath3)
End If
If Not IO.Directory.Exists(testPath4) Then
    MkDir(testPath4)
End If
If Not IO.Directory.Exists(testPath6) Then
    MkDir(testPath6)
End If
Jham
  • 17
  • 8

2 Answers2

1

To be honest MkDir isnt the quickest way to create directories, but for consistency, just use

RmDir(testPath1)

A better performing way would be to use..

My.Computer.FileSystem.CreateDirectory(testPath1)

to create a directory and ..

My.Computer.FileSystem.DeleteDirectory(testPath1,FileIO.DeleteDirectoryOption.DeleteAllContents)

to delete it/

David Wilson
  • 4,369
  • 3
  • 18
  • 31
  • but looks like database inside of the folders has been locked. what codes I will be using to unlock it so that the folder will be deleted? – Jham Jan 23 '16 at 08:07
  • how about releasing(unlock) database? so that i can delete the folder immediately using a button? – Jham Jan 23 '16 at 12:03
  • Well, you'll have to close all the open connections to the databases that you want to delete. If they have been opened using your program then it should be straightforward. If the connections have been opened by another program, it's more of a problem. – David Wilson Jan 23 '16 at 16:55
  • i have closed it uging connection.close() but still not working. 3 – Jham Jan 25 '16 at 11:17
  • how about counting the rows inside of the database? – Jham Jan 25 '16 at 12:01
  • I'm not sure what you're asking. You just want to know how to count the number of rows in a database table? – David Wilson Jan 25 '16 at 15:15
  • yah. with the use of vb.net, anyway i am using ADOX.Catalog and OleDb to create a database. – Jham Jan 25 '16 at 15:57
  • just use the .Rows.Count property of the datatable – David Wilson Jan 25 '16 at 16:22
  • how it is? sorry im just a beginner. – Jham Jan 26 '16 at 08:17
  • hey! do you know how to connect the databases through using openfiledialogbox? – Jham Jan 26 '16 at 13:09
  • Hi David, can you help me select multiple items in Listbox? – Jham Jan 28 '16 at 12:31
  • To be honest I don't have enough free time to write programs. Getting all the information is very time consuming. I did find this link for you about multi selecting listbox items though. http://stackoverflow.com/questions/5488211/multi-select-list-box – David Wilson Jan 29 '16 at 09:20
  • i get it now David, thanks to you. How about create a copy of mdb and convert it into excel? do you know how? – Jham Jan 29 '16 at 09:27
  • Not a clue I'm afraid. Do you have a copy of MS Access? You might be able to export the mdb as a csv file and import it into access. To do it programattically,I dont have any experience of working with excel files. There seems to be plenty of results on google to convert mdb to excel files though. – David Wilson Jan 29 '16 at 09:32
  • ah, okay. anyway, i've been searching for an hours but it seems those given codes by google are not compatible by mine. it seems like, maybe i will going to solve it by my own. 3 – Jham Jan 29 '16 at 09:40
  • You could try posting another question on Stack Overflow, but as you havent got any code for it yet, you might not get much help. You could also try the Stack exchange Super User site. – David Wilson Jan 29 '16 at 09:43
  • i got my limit on Stack Overflow, it seems 3days more left so that i can post a question. – Jham Jan 29 '16 at 09:45
  • Well. If you dont post a question then you wont get an answer, but if you do post a question, then you might get an answer. Trying is better than not trying :-) – David Wilson Jan 29 '16 at 09:59
  • Wew, i am just trying to say that i've been blocked by stackoverflow that cause me to not post a question. but i do really like to post, it helped me a lot after all. – Jham Jan 29 '16 at 10:23
  • Oops. Maybe you could create a new account with a different email address. and make sure to have a look here [ask] and here [mcve] to post better questions :-) Do you mind if I ask what you got blocked for? – David Wilson Jan 29 '16 at 10:27
  • It seems like if you've asked for more than 7 questions, you will be blocked by 1week and 3days. Maybe because I only have 5 reputation yet. – Jham Feb 01 '16 at 12:32
  • Hi David, could you please give me a sample of zooming using mousewheel and cropping using button. Please I need it badly. :'( help me pls! :'( – Jham Nov 16 '16 at 10:50
0

You can't. My answer had nothing to do with using databases. Which is why I apologised for misreading your original question. I should delete it and let someone else answer.

David Wilson
  • 4,369
  • 3
  • 18
  • 31
  • Hi David, could you help me browse an mdb file through using openfiledialog and update inside of it through datagridview tool? – Jham Jan 27 '16 at 13:39