Martijn van Dru Posted June 22, 2003 Posted June 22, 2003 Does anybody know what the syntax is from a delete command when you use for example a value of a textbox (it's a DELETE command for an ExecuteNonQuery command) I tried the following: Dim squery As String = " DELETE FROM Table1 WHERE (ID = '" & textbox1.Text & "')" I hope someone can help Martijn Quote
*Gurus* Derek Stone Posted June 22, 2003 *Gurus* Posted June 22, 2003 Dim sQuery As String = "DELETE FROM [Table1] WHERE [Table1].[iD] = '" & TextBox1.Text.Replace("'", "''") & "'" ... should work just fine assuming that the field "ID" was defined in the table as a string or character value. Quote Posting Guidelines
Lenin82 Posted June 22, 2003 Posted June 22, 2003 Dim Squery As String = "Delete FROM Table1 WHERE ID=" & txtBox.Text Thats what works for me, I was trying ID = 'ID NUMBER' but never got it working had to the remove both ' for it to work properly. Am using office 2000 dont know if that has anything to do with it Quote
Moderators Robby Posted June 23, 2003 Moderators Posted June 23, 2003 If the ID field is of numeric type then .... Dim Squery As String = "Delete FROM Table1 WHERE ID=" & convert.toint32(txtBox.Text) Quote Visit...Bassic Software
Martijn van Dru Posted June 23, 2003 Author Posted June 23, 2003 Thanks, I tried it with Dim sQuery As String = "DELETE FROM Table1 WHERE ID = "& txtBox.Text And it works for strings and integers Goodbye, Martijn Quote
abi_sara2001 Posted June 23, 2003 Posted June 23, 2003 Dim squery As String = " DELETE FROM Table1 WHERE ID = '" & textbox1.Text & "'" This should work. Try this. all the best. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.