Results 1 to 11 of 11

Thread: Opening Database [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004

    Opening Database [RESOLVED]

    I am trying to open a database using a data control, however, I cannot use the OpenDatabase function. (yes, I am a noobie to VB.) How can I do this?

    Code:
         ' Bring up a load window
        cdbDialog.DialogTitle = "Open database. . ."
        cdbDialog.Filter = "Database (*.mdb, *.xls)|*.mdb;*.xls"
        cdbDialog.FileName = "mydata.xls"
        cdbDialog.ShowSave
        
        If (cdbDialog.FileName <> "") Then
            ' Close the current database
            dtaMagicBase.Close
            ' Open the new database
        End If
    Last edited by Darkwraith; Jul 18th, 2003 at 03:00 PM.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    what kind of datacontrol are you using ? DAODC or ADODC ?
    -= a peet post =-

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    I believe it is DAODC (the control that has the default name of Data1. )
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    I could use the ADODC if need be. I was thinking of putting the database in Access anyway...
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    I decided to go with an Access database and a data control, but I still cannot get back the database after I close it.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Morning Darkwraith, sorry to say, but I do not have any good suggestions on the subject.... (I don't use bound controls)

    Before you go further with bound data controls, you should read this : http://www.vbrad.com/pf.asp?p=Articl...nding_evil.htm

    -= a peet post =-

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Good Morning (or night w/e the case may be) Peet.

    I dropped the data control because I found that the FAQ was actually more helpful than my books and converted to ADODC.

    If you have something for ADODC to open an Access database, it would be helpful and much appreciated.

    The code is pretty much the same.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  8. #8
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    oh its morning

    VB Code:
    1. Dim sConnString As String
    2.    
    3.      ' Bring up a load window
    4.     cdbDialog.DialogTitle = "Open database. . ."
    5.     cdbDialog.Filter = "Database (*.mdb, *.xls)|*.mdb;*.xls"
    6.     cdbDialog.FileName = "mydata.xls"
    7.     cdbDialog.ShowSave
    8.    
    9.     If (cdbDialog.FileName <> "") Then
    10.         ' Open the new database
    11.         sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & cdbDialog.FileName & ";Persist Security Info=False"
    12.         dtaMagicBase.ConnectionString = sConnString
    13.         dtaMagicBase.RecordSource = "Consumables"
    14.         dtaMagicBase.Refresh
    15.     End If

    does the job
    -= a peet post =-

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Thx! It works.

    Question, though. Do I have to explicitly tell it to close or will it implicitly free whatever resources it took to open the previous database?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  10. #10
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Dont think you have to close it. If you test it, and then open another db without the app crashing, then the new connectionstring has reset the data object.
    -= a peet post =-

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Thx for the information!
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

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