TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vergel aranas
NA
70
17k
multipledelete
Jul 10 2012 12:42 PM
Hi Sir, I'm here again hopping for your help. Sir, how can i delete multiple row in list view with mysql? I have already a code for deleting but it work only in one row and when i check and select more than one row it doesn't. How can i do that sir. Here is my code for delete.
private void btnPdel_Click(object sender, EventArgs e)
{
foreach(int t in petlist.CheckedIndices)
{
string s = petlist.Items[t].Text.ToString();
if (petlist.SelectedItems.Count > 0 )
{
ListViewItem lv = petlist.SelectedItems[0];
string cid = lv.SubItems[6].Text;
string petdel = "Delete from petreg where petId = '" + s + "' and clientId ='" + cid + "'";
MySqlConnection connect = new MySqlConnection(conn);
MySqlCommand cmd = new MySqlCommand(petdel, connect);
connect.Open();
int execute = 0;
execute = cmd.ExecuteNonQuery();
connect.Close();
if (execute.Equals(1))
{
petload();
MessageBox.Show("Data was succesfully deleted", "Mysql says...", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("The data is protected", "Error message", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}
}
Thanks Sir.
Reply
Answers (
5
)
Combobox and checkboxlist
academic year