Results 1 to 6 of 6

Thread: ADO.ADDNEW

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    Angry

    Code:
    Private Sub LogUser(UsrName As String)
    SQL = "SELECT UserName FROM LoggedUsers WHERE UserName = " & "'" & UsrName & "'"
    CheckUserRecord.Close
    CheckUserRecord.Open SQL, MeterInfo
    With CheckUserRecord
        If .EOF Then
            .AddNew
            !UserName = UsrName
            .Update
        End If
        .Close
    End With
    End Sub
    gives me error
    "object or provider is not capable of performing the operation"

    damn ADO... dao was easier

  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Try this ...

    Code:
    Private Sub LogUser(UsrName As String)
    
    SQL = "SELECT UserName FROM LoggedUsers WHERE UserName = '" & UsrName & "'"
    
    CheckUserRecord.Open SQL, MeterInfo
    
    If CheckUserRecord.EOF Then 
    
      CheckUserRecord.Close
      
      CheckUserRecord.CursorType = adOpenKeyset
      CheckUserRecord.Open "LoggedUsers", MeterInfo, , , adCmdTable
      
      CheckUserRecord.AddNew
      
      CheckUserRecord!UserName = UsrName
      
      CheckUserRecord.Update
    
    End If
    
    CheckUserRecord.Close
    
    End Sub
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

  3. #3
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Cool Ado Methods for Changing records

    Hi there,

    Before opening the connection ensure you have set the ado locktype and cursortype properties, since by default the go to read only. You can also test using the 'supports' property to check if updating is allowed.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    still get the error

    Code:
    Private Sub LogUser(UsrName As String)
    SQL = "SELECT UserName FROM LoggedUsers WHERE UserName = " & "'" & UsrName & "'"
    CheckUserRecord.Close
    CheckUserRecord.Open SQL, MeterInfo
    With CheckUserRecord
        If .EOF Then
            .Close
            .CursorType = adOpenKeyset
            .Open "LoggedUsers", MeterInfo, , , adCmdTable
            .AddNew
            !UserName = UsrName
            .Update
        End If
        .Close
    End With
    End Sub

  5. #5
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    That works for me except I also have the line

    Code:
    CheckUserRecord.LockType = adLockOptimistic
    just after

    Code:
    CheckUserRecord.CursorType = adOpenKeyset
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    Talking hehe dats funny...

    i been waiting for a reply.. maybe 25 min
    then am like "grr got to figure this out on my own"

    i did
    came back
    and boom stevie said same thing as i did

    thanks for all the help guyz

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