Results 1 to 8 of 8

Thread: [RESOLVED] Databse Problem...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Resolved [RESOLVED] Databse Problem...

    I am tryin to create a form for my database in vb6.

    the tables were made in access and saved to the harddrive

    i add a data control to the form and set the DatabaseName to the access database i have created...

    i then try to set the RecordSource to a table in the database, however when i click on the drop down arrow to select the table ann error message comes up stating that a '.mdb' is an unrecognised database format????

    any help would be greatly appreciated

    GTJ

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Databse Problem...

    what version of access?
    and what is the control using to connect, ADO or DAO?

    pete

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Databse Problem...

    Access 2000 and what is ADO or DAO?

  4. #4
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: Databse Problem...

    Quote Originally Posted by greythej
    I am tryin to create a form for my database in vb6.

    the tables were made in access and saved to the harddrive

    i add a data control to the form and set the DatabaseName to the access database i have created...

    i then try to set the RecordSource to a table in the database, however when i click on the drop down arrow to select the table ann error message comes up stating that a '.mdb' is an unrecognised database format????

    any help would be greatly appreciated

    GTJ
    Before you use Bound Controls you should Read This Article entitled "Why Data Binding and the like are evil" (Link courtesy of Hack).

    Here is what I use to connect to an Access Database:

    VB Code:
    1. Dim cn As adodb.Connection
    2. Dim rs As adodb.Recordset
    3. Dim strSQL As String
    4. Dim a As Single
    5. Dim strConnectString as String
    6. Dim strDBCursorType As String
    7. Dim strDBLockType As String
    8. Dim strDBOptions As String
    9.  
    10. strDBCursorType = adOpenDynamic  'CursorType
    11. strDBLockType = adLockOptimistic   'LockType
    12. strDBOptions = adCmdText         'Options
    13.  
    14. Set cn = New adodb.Connection
    15.  
    16. ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    17.                       "Data Source=" & App.Path & "\[color="#FF0080"][B]YourDatabaseName.mdb[/B][/color]" & _
    18.                       ";Jet OLEDB:Engine Type=5;"
    19.  
    20. cn.Open ConnectString
    21.    
    22.     With cn
    23.         .CommandTimeout = 0
    24.         .CursorLocation = adUseClient
    25.     End With
    26.  
    27. Set rs = New adodb.Recordset       'Creates record set
    28.  
    29. strSQL = "SELECT * "
    30. strSQL = strSQL & "FROM [B][color="#FF0080"]YourTableName[/color][/B];"
    31.  
    32. rs.Open strSQL, cn, strDBCursorType, strDBLockType, strDBOptions
    33.  
    34. If rs.RecordCount = 0 Then
    35.     MsgBox "No Records"
    36. Else
    37.  
    38.     For a = 1 To rs.RecordCount ' Loops through Recordset
    39.  
    40.         'Put your code here
    41.          Me.Text1.Text = [B][color="#FF0080"]rs!FieldName1[/color][/B] & ""
    42.          Me.Text2.Text = [B][color="#FF0080"]rs!FieldName2[/color][/B] & ""
    43.             '.....
    44.  
    45.         rs.MoveNext
    46.     Next a
    47.  
    48. End If
    49.  
    50. rs.Close
    51. Set rs = Nothing
    52. cn.Close
    53. Set cn = Nothing

    Change the Code in Red to the names of your schema.
    Last edited by Mark Gambo; May 29th, 2005 at 12:32 PM.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  5. #5
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: Databse Problem...

    data controll doesn't recognize access 2000 or higher's database, you have to download sp6 and mdac at microsoft

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Location
    England
    Posts
    283

    Re: Databse Problem...

    visual basic sp6 or access sp6?

  7. #7
    Hyperactive Member
    Join Date
    Mar 2005
    Location
    Manila, Philippines
    Posts
    486

    Re: Databse Problem...

    vb sp6

  8. #8
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Databse Problem...

    And the latest MDAC....
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

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