Results 1 to 5 of 5

Thread: Howto change Database name and Recordsource at runtime?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    112

    Question Howto change Database name and Recordsource at runtime?

    hi
    i want to change connection(database) and command1's RecordSource (Tables) of DataGrid??

  2. #2
    Hyperactive Member
    Join Date
    Sep 2005
    Posts
    376

    Re: Howto change Database name and Recordsource at runtime?

    I'm not really sure what you are trying to do here. Can you elaborate maybe step by step what is happening and what you need to happen

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    112

    Re: Howto change Database name and Recordsource at runtime?

    Private Sub Command4_Click()
    Dim dbn As String
    dbn = "C:\windows\desktop\sarfraz\p\data\"
    DataEnvironment1.Connection1.ConnectionString = dbn & Form8.List1.ListIndex & ".mdb"
    message 3705 object is open (etc...)

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Howto change Database name and Recordsource at runtime?

    You can't rename a file (any file) while that file is open.

    So, to do what you want, your program must first, close the database and remove all connections to it. Then, you can do a rename and reset the recordsource.

  5. #5
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: Howto change Database name and Recordsource at runtime?

    basically this is what hack was trying to say.
    VB Code:
    1. dataenvironment1.connection1.close
    2. dataenvireonment1.connection1.connectionstring=newdb

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