Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
how can remove this error index was out of range ????????
kamal dhillon
Sep 26 2012 3:56 PM
2k
Reply
private void button1_Click(object sender, EventArgs e)
{
SqlCommand delcmd = new SqlCommand();
string empid = Convert.ToString("@empid");
while (true)
{
if (dataGridView1.Rows.Count > 1 && dataGridView1.SelectedRows[0].Index != dataGridView1.Rows.Count - 1 )/////////////error
{
delcmd.CommandText = "DELETE FROM registrationn WHERE empid=" + dataGridView1.SelectedRows[0].Cells[0].Value.ToString() + "";
con.Open();
delcmd.Connection = con;
delcmd.ExecuteNonQuery();
con.Close();
dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
MessageBox.Show("Employee deleted");
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
how to store date time values in database and also i want to store screenshot pictures in particular folder ????
Is the DbContext class defined and used differently in the version of C# for Visual Studio 2012 than in Visual Studio 2010?