Results 1 to 5 of 5

Thread: How to delete a ROW that i click from FLEXSRID?

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    53

    How to delete a ROW that i click from FLEXSRID?

    here is my code
    Code:
      
        On Error GoTo ErrDelete
            
            Dim sqlStr As String
                If MsgBox(" ", vbQuestion + vbYesNo, " Deleted ") = vbYes Then
                    sqlStr = " Delete STR_ITEMNO,STR_FLOWER,STR_QTY from STRUCTURE "
                
                Else
                    Exit Sub
                End If
                Conn.BeginTrans
                Conn.Execute sqlStr
                Conn.CommitTrans
                
                MsgBox ""
    ExitError:
        Exit Sub
    ErrDelete:
        Conn.RollbackTrans
        MsgBox "Error:" & Err.Description, vbCritical
        Resume ExitError
        
        Unload Me
        Form1.Show
    but it will delete my all data in table,
    if i choose delete from strucuture where str_itemno...
    it will delete my all foreign-key,
    i want to delete one row at a time then my foreign-key will allow to be redundant...


    plse help me..

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to delete a ROW that i click from FLEXSRID?

    Thread moved to 'Database Development' forum (the 'VB6' forum is only meant for questions which don't fit in more specific forums)

    The Delete statement always deletes entire rows, so listing fields does not make sense (either use * or nothing).

    It will also delete all rows from the table unless you give it a Where clause which specifies the row(s) to delete. What you should use in the Where clause depends on your application and database, but is likely to be something like "WHERE uniqueField = value".

    I don't know what you meant by "it will delete my all foreign-key", but it sounds like you are not using the correct condition(s) in the Where clause.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2010
    Posts
    53

    I cant delete,

    HERE IS MY CODE
    Code:
    Private Sub CmdDelete_Click()
    
     On Error GoTo ErrDelete
            
            Dim sqlStr As String
                If MsgBox(" You want to DELETE this Record?", vbQuestion + vbYesNo, " Deleted ") = vbYes Then
                    sqlStr = " Delete STR_ITEMNO,STR_FLOWER,STR_QTY from STRUCTURE where STR_ITEMNO='" & TextItemNum.Text & "'"
                
                Else
                    Exit Sub
                End If
                Conn.BeginTrans
                Conn.Execute sqlStr
                Conn.CommitTrans
                
                MsgBox "Record Deleted"
                Unload Me
                FormStructure.Show
                
    ExitError:
        Exit Sub
    ErrDelete:
        Conn.RollbackTrans
        MsgBox "Error:" & Err.Description, vbCritical
        Resume ExitError
                    
                    
    End Sub
    I WANT TO DELETE RECORD FROM STRUCTURE
    Last edited by mcapon; Oct 5th, 2010 at 10:09 AM.

  4. #4
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: I cant delete,

    You'll have to be more precise than that. What do you mean by "can't delete". Do you get an error or what?

    EDIT: Just looked at the SQL statement. I'm not sure DELETE can be used like that. Isn't it for deleting an entire record, not just clearing some fields in a record?! You'll have to use UPDATE to do that.
    Last edited by baja_yu; Oct 5th, 2010 at 09:49 AM.

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: How to delete a ROW that i click from FLEXSRID?

    Duplicate threads merged - please post each question (or variation of it) only once.

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