Author |
Topic |
Iain Duthie
Starting Member
17 Posts |
Posted - 2005-01-14 : 09:26:48
|
I have a multiple sql statement that is used to delete a row of data from a database. At the moment it only deletes rows that have no blank cells but I need it to also delete rows with blank cells. I was wondering if someone could point me in the right direction.CheersIain. |
|
jhermiz
3564 Posts |
Posted - 2005-01-14 : 10:58:27
|
So you want to delete all rows ? Keeping the web experience alive -- [url]http://www.web-impulse.com[/url] |
 |
|
Iain Duthie
Starting Member
17 Posts |
Posted - 2005-01-14 : 11:28:19
|
No I have a check box attached to each row and when I check a box it search deletes that one but only if there is text in all the cells. |
 |
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2005-01-14 : 16:14:20
|
Maybe you could post the SQL statement your using now?===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
 |
|
Iain Duthie
Starting Member
17 Posts |
Posted - 2005-01-17 : 04:08:02
|
SqlCommand sqlCmd = new SqlCommand("DELETE from catalog_list WHERE ((format = '"+ format[i].ToString() + "')AND(drawing_no = '" + drawing_no[i].ToString() +"')AND(group_code = '" + group_code[i].ToString() + "')AND(title = '" +title[i].ToString() + "')AND(drawn_by = '" + drawn_by[i].ToString() +"')AND(area = '" + area[i].ToString() + "')AND(sheetno = '" +sheetno[i].ToString() + "')AND(total_sheets = '" + total_sheets[i].ToString() +"')AND(location = '" + location[i].ToString() + "'))" ,sqlConnection1); sqlCmd.Connection = sqlConnection1;sqlConnection1.Open();sqlCmd.ExecuteNonQuery();sqlConnection1.Close(); |
 |
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2005-01-17 : 09:59:55
|
Hmmm. Let me phrase my question a little differently. Can you post the SQL statement that this generates?===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
 |
|
Iain Duthie
Starting Member
17 Posts |
Posted - 2005-01-18 : 09:46:31
|
It deletes the row, but only if there are no empty cells. If there is an empty cell it doesn't do anything. |
 |
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2005-01-18 : 15:19:52
|
The problem is that the DELETE statement is trying to find which row to delete based on a match of the contents of the cells. The problem (other than this being a dangerous way to do deletes) is that if a row actually does not contain data (is null) your statement is treating that like an empty string, which is not necessarily the same thing. So you do not get a match. NULL does not equal NULL. You test for Null by using IS NULL or IS NOT NULL.BUT the better way to issue this delete statement would be to provide the Primary Key as your WHERE clause rather than the contents of the row.---------------------------------------------------------------------------------Infoneering: Information Technology solutions engineered to professional standards. |
 |
|
jhermiz
3564 Posts |
Posted - 2005-01-18 : 18:46:28
|
Might want to make this a stored procedure as well. Keeping the web experience alive -- [url]http://www.web-impulse.com[/url] |
 |
|
Iain Duthie
Starting Member
17 Posts |
Posted - 2005-01-20 : 09:12:21
|
The problem with making the primary the where clause is that a lot of the data is duplicated. |
 |
|
Iain Duthie
Starting Member
17 Posts |
Posted - 2005-01-21 : 09:49:14
|
I have got it working now thank you for your helpCheers Iain |
 |
|
|