Results 1 to 11 of 11

Thread: ADOX Question

  1. #1

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935

    ADOX Question

    I have used ADOX to create a new database

    It works fine and the new db is built

    owever I have done nothing with setting security on the database

    and when I go to open this new db in access so I can verify all the tables are correct It prompts me for a username and password

    does anyone know how to prevent this from happening?

  2. #2
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    How do you create the db?

  3. #3

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    This is the code

    VB Code:
    1. Public Function CreateDB(strPath As String) As Boolean
    2. Dim cat As ADOX.Catalog
    3. Dim tbl As ADOX.Table
    4.  
    5. 'On Error GoTo errorHandler
    6.  
    7. Set cat = New ADOX.Catalog
    8. Set tbl = New ADOX.Table
    9.  
    10. cat.Create "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & strPath
    11.  
    12. With tbl
    13. .Name = "Clients"
    14. .Columns.Append "User", adVarWChar, 50
    15. .Columns.Append "IP", adVarWChar, 16
    16. End With
    17.  
    18. cat.Tables.Append tbl
    19.  
    20. Set tbl = Nothing
    21. Set tbl = New ADOX.Table
    22.  
    23. With tbl
    24. .Name = "Data"
    25. .Columns.Append "Path", adVarWChar, 250
    26. .Columns.Append "Name", adVarWChar, 250
    27. .Columns.Append "Exe", adVarWChar, 250
    28. End With
    29.  
    30. cat.Tables.Append tbl
    31.  
    32. Set tbl = Nothing
    33. Set tbl = New ADOX.Table
    34.  
    35. With tbl
    36. .Name = "Office"
    37. .Columns.Append "Username", adVarWChar, 250
    38. .Columns.Append "Password", adVarWChar, 250
    39. .Columns.Append "Num", adInteger
    40. End With
    41.  
    42. cat.Tables.Append tbl
    43.  
    44. Set tbl = Nothing
    45. Set tbl = New ADOX.Table
    46.  
    47. With tbl
    48. .Name = "Teachers"
    49. .Columns.Append "Username", adVarWChar, 250
    50. .Columns.Append "Password", adVarWChar, 250
    51. .Columns.Append "Num", adInteger
    52. End With
    53.  
    54. cat.Tables.Append tbl
    55.  
    56. Set tbl = Nothing
    57. Set tbl = New ADOX.Table
    58.  
    59. With tbl
    60. .Name = "Students"
    61. .Columns.Append "Username", adVarWChar, 250
    62. .Columns.Append "Password", adVarWChar, 250
    63. .Columns.Append "Num", adInteger
    64. End With
    65.  
    66. cat.Tables.Append tbl
    67.  
    68. Set tbl = Nothing
    69. Set tbl = New ADOX.Table
    70.  
    71. With tbl
    72. .Name = "Settings"
    73. .Columns.Append "School Details", adVarWChar, 250
    74. .Columns.Append "Admin Pass", adVarWChar, 250
    75. .Columns.Append "Internet Pass", adVarWChar, 250
    76. .Columns.Append "Pass Enabled", adBoolean
    77. .Columns.Append "NumLic", adInteger
    78. End With
    79.  
    80. cat.Tables.Append tbl
    81.  
    82. CreateDB = True
    83. Exit Function
    84.  
    85. errorHandler:
    86. CreateDB = False
    87.  
    88. End Function

  4. #4
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    try resetting the catalog with the tbl

  5. #5
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Also at the end of the funstion set cat to nothing!
    Your leaving it open!!!

  6. #6
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    i think the user is 'admin' and the password is blanc ''.

    hth.
    calle

  7. #7
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Yep but it shouldnt do that when creating a db in code!
    Rudvs2: Hows it going??

  8. #8

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    Sorry for not responding Beacon I went home for a sleep.

    I still havnt got it working


    And just to note If i Try to use Admin and blank password to open the db that it creates I just get an unkown user error

    Im going to start slogging through MSDN now but if you have had any more thoughts it would be appreciated

  9. #9
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    ok this is how i do it. Compare if you need too perhaps that'll help:

    Private Sub Command1_Click()
    'creating the database.
    ' create the table
    Set cat = New ADOX.Catalog
    Set tbl = New ADOX.Table

    cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.mdb"

    With tbl
    .Name = "Table1"
    ' Create fields and append them to the
    ' Columns collection of the new Table object.
    With .Columns
    .Append "PicID"
    .Append "Description", adVarWChar, 255
    .Append "Picture", adLongVarBinary
    End With
    End With

    ' Add the new Table to the Tables collection of the database.
    cat.Tables.Append tbl

    Set cat = Nothing
    Set tbl = Nothing
    MsgBox "Done", vbInformation, "File Created"
    End Sub

  10. #10

    Thread Starter
    Fanatic Member rudvs2's Avatar
    Join Date
    Mar 2001
    Location
    NZ
    Posts
    935
    I think I have found the problem

    It appears to be my Access 2000 that is the trouble not my code (whew) because I cant open any databases now without getting prompted for this password

    so im just reinstalling

  11. #11
    New Member
    Join Date
    Aug 2003
    Posts
    1
    I have created a database using ADOX. But now i would like to create a table using user input (text1.text) into the database. How do i open the database using ADOX?

    Thank you.

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