CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: ADO Problem

  1. #1
    Join Date
    Dec 2000
    Location
    Colombo,Srilanka
    Posts
    50

    ADO Problem

    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

  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: ADO Problem

    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
    [email protected]

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Dec 2000
    Location
    Colombo,Srilanka
    Posts
    50

    Re: ADO Problem

    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

  4. #4
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: ADO Problem

    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
    [email protected]

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  5. #5
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: ADO Problem

    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

  6. #6
    Join Date
    Dec 2000
    Location
    Colombo,Srilanka
    Posts
    50

    Re: ADO Problem

    Thankx for the reply.

    Yes I agree with you,
    Is there any way I can set the default path



    Dinesh Asanka

  7. #7
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: ADO Problem

    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
    [email protected]

    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
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  8. #8
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: ADO Problem

    Use the CHDIR$ function

    John G

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured