Click to See Complete Forum and Search --> : ADO Problem
dineshasanka
October 8th, 2001, 05:55 AM
Hi gurus,
In my Application there is a option to open a text file.I'm using Common dialog to do that.After I open a file in a floppy,then I exit my application an run it again,It is looking for the floppy drive when it is opening the database.I'm using ADO for the Opendatabase.
Do u know any clue about this.
Thankx in advance
Dinesh Asanka
Cakkie
October 8th, 2001, 07:01 AM
This has got nothing to do with ADO, this has got to do with the Commondialog control. By default, the commondialog control opens with the path of the application. After you select a file with it, it will remember the location of that file when using it a second time. This happens until you quit your application. But when running in the VB IDE, it will keep it's value until the control is unloaded, and that is when you close the VB IDE, or close the project. You can override this behaviour by using the initdir property, which will open a specific folder.
CommonDialog1.InitDir = "c:\"
CommonDialog1.ShowOpen
This code will always open the Commondialogconrol in c:\, even if you selected a file on a:
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
dineshasanka
October 8th, 2001, 07:12 AM
Thankx for the answer.
But actually that error comes when I'm open the database again.Not at the common dialog box.I set the common dialog box values normally as u mentioned.
But it gives the error at the time of opening the database.
Dinesh Asanka
Cakkie
October 8th, 2001, 07:19 AM
Are you opening the database from floppy, or is that text file you are talking about the only thing you need on floppy? Also, could you provide the code used for opening the database (including some lines of the commondialog control).
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
John G Duffy
October 8th, 2001, 07:46 AM
Your OpenDatBAse statement supplies the drive/path/name of the location of your database. If you omit drive or path, then VB will use the default, Whatever it currently is. In your case, selecting A: from the commonDialog control apparently sets the default to "A:/"
John G
dineshasanka
October 8th, 2001, 10:19 PM
Thankx for the reply.
Yes I agree with you,
Is there any way I can set the default path
Dinesh Asanka
Cakkie
October 9th, 2001, 01:31 AM
You can use hte SetCurrentDirectory API Function for thet
[vbcode]
' in a module
Public Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long
' in a form
SetCurrentDirectory "C:\"
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
John G Duffy
October 9th, 2001, 02:13 PM
Use the CHDIR$ function
John G
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.