Guest aXiS_PoWeR Posted November 7, 2002 Posted November 7, 2002 can anyone tell me an SQL command for adding or deleting a field from SQL Server 2000 using a objCmd.ExecuteNonQuery() ? Quote
*Gurus* Derek Stone Posted November 7, 2002 *Gurus* Posted November 7, 2002 objCmd.CommandText = "DELETE * FROM myTable WHERE ID > 0" objCmd.ExecuteNonQuery() Quote Posting Guidelines
Guest aXiS_PoWeR Posted November 8, 2002 Posted November 8, 2002 lol...i need the table just need to delete or add a column or 2 Quote
Guest bkellis Posted November 25, 2002 Posted November 25, 2002 Can you use the "ALTER TABLE" command? Quote
Moderators Robby Posted November 26, 2002 Moderators Posted November 26, 2002 Sorry dexmix, I couldn't help but laugh. :) Quote Visit...Bassic Software
Guest wild wolf Posted November 27, 2002 Posted November 27, 2002 objCmd.CommandText = "DELETE * FROM myTable WHERE ID > 0" objCmd.ExecuteNonQuery() hi Derek, i have the following code, command.CommandText = "DELETE * FROM table WHERE item_id LIKE "+noBox.Text; command.ExecuteNonQuery(); and an exception error is caught saying "Syntax error near '*' " what can the error be? Quote
wyrd Posted November 27, 2002 Posted November 27, 2002 Change "DELETE * FROM table WHERE item_id LIKE "+noBox.Text to "DELETE * FROM table WHERE item_id LIKE '" + noBox.Text + "'" You have to put strings inside ' '. If the item_id is supposed to be a number then you'll need to cast noBox.Text to an Integer. Quote Gamer extraordinaire. Programmer wannabe.
Guest wild wolf Posted November 28, 2002 Posted November 28, 2002 Change "DELETE * FROM table WHERE item_id LIKE "+noBox.Text to "DELETE * FROM table WHERE item_id LIKE '" + noBox.Text + "'" You have to put strings inside ' '. If the item_id is supposed to be a number then you'll need to cast noBox.Text to an Integer. did not work, still says Syntax error near '*' asrar Quote
wyrd Posted November 28, 2002 Posted November 28, 2002 Hmm.. well what exactly is in noBox.Text? Just numbers like 1, 2, 3, etc.. or something like ID1, ID2, ID3, etc..? Quote Gamer extraordinaire. Programmer wannabe.
Guest wild wolf Posted November 28, 2002 Posted November 28, 2002 Hmm.. well what exactly is in noBox.Text? Just numbers like 1, 2, 3, etc.. or something like ID1, ID2, ID3, etc..? alphanumeric and the data type for item_id is also alphanumeric. asrar Quote
*Gurus* Derek Stone Posted November 28, 2002 *Gurus* Posted November 28, 2002 You have a table named "table"? Quote Posting Guidelines
Guest wild wolf Posted November 29, 2002 Posted November 29, 2002 hi, the table name is not table but journal_detail, i put table here just to clear things, sorry if i confused anyone. asrar Quote
*Gurus* Derek Stone Posted November 29, 2002 *Gurus* Posted November 29, 2002 sSQL = "DELETE * FROM journal_detail WHERE item_id LIKE '%" & noBox.Text & "%'" Give it one more shot. Quote Posting Guidelines
Guest wild wolf Posted December 2, 2002 Posted December 2, 2002 sSQL = "DELETE * FROM journal_detail WHERE item_id LIKE '%" & noBox.Text & "%'" Give it one more shot. hi did not work, the problem is not on how i take the input (i.e it has nothing to do with the noBox.Text), the problem is with the delete command, the error points me towards the * and says the error is before the * in that case its something to do with the delete keyword, and because of that there is a question i would like to ask, can we really use the delete command in this way? asrar Quote
wyrd Posted December 2, 2002 Posted December 2, 2002 You know, I haven't done actual SQL code in quite a while so I'm a bit rusty in trying to figure this out.. but I just did a search on http://www.mysql.com (yes I know you're using Access or SQL Server but mysql.com is still a great source to quickly look up generic SQL code) and they have the delete command listed like so; DELETE FROM table WHERE col = 'Stuff' Note the no * at all. Might as well give it a shot, nothing else seems to be working. :eek: Just remember to back up your database before toying with any sort of delete command. ;) Quote Gamer extraordinaire. Programmer wannabe.
Guest wild wolf Posted December 3, 2002 Posted December 3, 2002 BINGO wyrd, that did it!!!!! thanx alot :) asrar 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.