Results 1 to 2 of 2

Thread: What's with ADOX

  1. #1

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621

    Angry

    AAHHHHHH!!

    I am having a nightmare trying to add a user to a database.

    The code so far is as follows.
    Code:
    Public Function fn_ConnectDB() As Boolean
    On Error GoTo ConnectErr
    
                Set cnnMIS = New ADODB.Connection
                With cnnMIS
                    .Provider = "Microsoft.Jet.OLEDB.4.0"
                    .Properties("Jet OLEDB:System database") = GetSetting("WIPWOS", "Database", "System_DB", "Err")
                    .Open GetSetting("WIPWOS", "Database", "DBPath", "Err"), strUser, strPWD
                End With
        fn_ConnectDB = True
        Exit Function
        
    ConnectErr:
        Select Case Err
            Case Err
                lErrNumber = Err.Number
                sErrDescription = Err.Description
                sTitle = "Error in function fn_ConnectDB"
                fn_ConnectDB = False
                Err.Clear
        End Select
    End Function
    
    
    Private Sub cmdAddUser_Click()
    On Error GoTo AddErr
        Set cat = New ADOX.Catalog
        
        '\\Validate the relevant input boxes
        If IsNull(txtUserName) Or txtUserName = "" Then
            MsgBox "please input a User Name" _
                , vbOKOnly
            txtUserName.SetFocus
            GoTo Exit_AddErr
        End If
    
        If IsNull(txtPassword) Or txtPassword = "" Then
            MsgBox "please input a password," _
                , vbOKOnly
            txtPassword.SetFocus
            GoTo Exit_AddErr
        End If
        
        If IsNull(cboGroup) Or cboGroup = "" Then
            MsgBox "please choose a Group," _
                , vbOKOnly
            cboGroup.SetFocus
            GoTo Exit_AddErr
        End If
    
    
        '\\open database connection
        If Not DBUtils.fn_ConnectDB Then
            If sTitle = "" Then sTitle = "User error!"
            MsgBox lErrNumber & " " & sErrDescription, vbOKOnly, sTitle
            GoTo Exit_AddErr
        End If
        
        '\\Set catalog active connection to the DB connection
        cat.ActiveConnection = cnnMIS
        
        '\\Append the user to the database
        cat.Users.Append "Gary Lowe", "newpass"
        cat.Users(txtuser).Groups.Append cboGroup
    
        '\\Add user to the users table
        cnnMIS.BeginTrans
            cnnMIS.Execute " INSERT INTO tblUsers " _
              & "(User_Name, Password, Group ) VALUES " _
              & "('" & txtUserName & "' , '" & txtPassword & "', '" _
              & cboGroup & "');"
        cnnMIS.CommitTrans
        
    
    
    Exit_AddErr:
    
        Exit Sub
    
    AddErr:
        Select Case Err
            Case Err
                cnnMIS.RollbackTrans
                Resume Exit_AddErr
        End Select
    End Sub
    Everytime the code hits the
    Code:
    cat.Users.Append "Gary Lowe", "newpass"
    The error 3251 : Object or provider is not capable of performing requested operation.

    From what I have read in the ADO guide this means it can't actually do this (So why is it there).

    If anyone knows another way round this can you please help.

    Thanks

    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  2. #2
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Isle of Man
    Posts
    276
    I'm struggling with exactly the same problem, too.

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