Results 1 to 5 of 5

Thread: ADO.DELETE

  1. #1

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

    Angry

    apologies for too many posts fro me
    but i need to graps this ado...

    Code:
    Public Sub LogOffUser(UsrName As String)
        Dim LogOffUserRecord As ADODB.Recordset
        Set LogOffUserRecord = New ADODB.Recordset
        SQL = "SELECT * FROM LoggedUsers WHERE UserName = " & "'" & UsrName & "'"
        LogOffUserRecord.Open SQL, MeterInfo
        LogOffUserRecord.Delete
        Set LogOffUserRecord = Nothing
        End
    End Sub
    i get error on the logoffuserrecord.DELETE
    saying
    "object or provider is not capable of performing the operation"

    that code should return one record...
    and delete it

    according to help i read.. .DELETE is default and will delete the current record..

    i tried even typing the constants..
    still same error..

    thanks


  2. #2
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Why don't you try ...

    Code:
    strSQL = "DELETE FROM LoggedUsers WHERE UserName = '" & UsrName & "'"
    
    ConnectionObject.Execute strSQL
    Where ConnectionObject is your current connection.
    VB6 sp5, SQL Server 2000, C#

    There are no stupid questions. Only stupid people.

  3. #3

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

    :)

    i could use that..
    and did

    but i still like to know why my problem didn't work

    for future reference

  4. #4
    Member
    Join Date
    Aug 2000
    Posts
    51

    Exclamation

    I think your problem may be in the way you open your recordset. From your code it didn't look like you defined the type of cursor that should be used. When you don't define the type of cursor that should be used it used a forward-only cursor by default. The forward only cursor is a read-only recordset (can't add, edit or DELETE data). Try opening your recordset by using

    LogOffUserRecord.Open SQL, MeterInfo,adopendynamic

    Then you should be able to delete that record. I hope this works for you.

    Try experimenting with the various type of recordsets. I think, but am not sure, that only a subset of these cursors are available when you are working on an access database. They should all work when working on SQL Server. I think it is the dynamic cursor that isn't supported. I'm pretty sure that Access doesn't support server side cursors also. I'm getting a bit off the subject here, but these are things that may drive you crazy trying to figure out at some point that you wouldn't normally know if you didn't read.

  5. #5
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Originally posted by 666539
    I think your problem may be in the way you open your recordset. From your code it didn't look like you defined the type of cursor that should be used. When you don't define the type of cursor that should be used it used a forward-only cursor by default. The forward only cursor is a read-only recordset (can't add, edit or DELETE data). Try opening your recordset by using

    LogOffUserRecord.Open SQL, MeterInfo,adopendynamic

    Then you should be able to delete that record. I hope this works for you.

    Try experimenting with the various type of recordsets. I think, but am not sure, that only a subset of these cursors are available when you are working on an access database. They should all work when working on SQL Server. I think it is the dynamic cursor that isn't supported. I'm pretty sure that Access doesn't support server side cursors also. I'm getting a bit off the subject here, but these are things that may drive you crazy trying to figure out at some point that you wouldn't normally know if you didn't read.
    This a good indication why 'defaults' are sometimes bad...

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