|
-
Sep 28th, 2010, 11:31 AM
#1
Thread Starter
Member
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..
-
Sep 28th, 2010, 11:40 AM
#2
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.
-
Oct 5th, 2010, 09:36 AM
#3
Thread Starter
Member
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.
-
Oct 5th, 2010, 09:43 AM
#4
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.
-
Oct 5th, 2010, 11:14 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|