Results 1 to 2 of 2

Thread: How to open database with VB????

  1. #1
    Guest

    Question

    Hi,

    I am trying to open Access database by using Data Control of VB.
    I set the path name under the property (DatabaseName) of the Data Control.

    When i try to run it, i am getting error as following:

    "Unrecognized database format 'C:\----' "

    I don't understand why i am getting this error.

    Please help me !
    Thank you.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'open database and set database and recordset
    Option Explicit
    
    Public Db as database, Rs as recordset
    Public cDName As String
    Public cTblName as String
    
    Public Sub OpenDB()
    
            	Dim AppPath$
                
            If Right(App.Path, 1) <> "\" Then _
            	AppPath = App.Path & "\" _
            Else AppPath = App.Path
            
            	cDBName = AppPath & "YourDatabaseName.mdb"
            
            	cTblName = "YourTableName"
    
            	Data1.DatabaseName = cDBName
            	Data1.RecordSource = cTblName         
            	
       	 End Sub
    
    Private Sub Form_Load()
    '
          Call OpenDB
    '
          Set db = Workspaces(0).OpenDatabase(cDBName)
          Set rs = db.OpenRecordset(cTblName)
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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