here its my code
everything works fine but im getting this error
and cant get around.
<Input string was not in a correct format.> and it points where in red up
And when i delete that row i get this
<<<<Collection was modified; enumeration operation might not execute.>>
here its the code
private void buttonDelete_Click(object sender, EventArgs e) { SqlConnection thisConnection = new SqlConnection(@"server=(local);Integrated security=true;" + "database=NLHdatabase"); // SqlDataAdapter thisAdapter = new SqlDataAdapter("SELECT DoctorID,LastName,FirstName,Specialty FROM Doctors", thisConnection); // SqlCommandBuilder thisbuilder = new SqlCommandBuilder(thisAdapter); // DataSet thisdataset = new DataSet(); // thisAdapter.Fill(thisdataset, "Doctors"); // DataColumn[] keys = new DataColumn[1]; keys[0] = thisdataset.Tables["Doctors"].Columns["DoctorID"]; thisdataset.Tables["Doctors"].PrimaryKey = keys; DataRow theRow = thisdataset.Tables["Doctors"].Rows.Find("DoctorID"); //-->[color="#FF0000"]HERE[/color] // foreach (DataRow FindtheRow in thisdataset.Tables["Doctors"].Rows) { if (FindtheRow["DoctorID"].ToString() == comboBoxdeletedoctor.Text) { // theRow["DoctorID"] = comboBoxdeletedoctor.Text; // theRow["LastName"] = textBoxFN.Text; // theRow["FirstName"] = textBoxNAme.Text; // theRow["Specialty"] = comboBoxSpeciality.Text; FindtheRow.Delete(); thisAdapter.Update(thisdataset, "Doctors"); FindtheRow.AcceptChanges(); } thisConnection.Close(); } Administration main = new Administration(); main.Visible = true; main.Activate(); textBoxFN.Clear(); textBoxNAme.Clear(); this.Hide(); }
everything works fine but im getting this error
and cant get around.
<Input string was not in a correct format.> and it points where in red up
And when i delete that row i get this
<<<<Collection was modified; enumeration operation might not execute.>>
here its the code
private void buttonDelete_Click(object sender, EventArgs e) { SqlConnection thisConnection = new SqlConnection(@"server=(local);Integrated security=true;" + "database=NLHdatabase"); // SqlDataAdapter thisAdapter = new SqlDataAdapter("SELECT DoctorID,LastName,FirstName,Specialty FROM Doctors", thisConnection); // SqlCommandBuilder thisbuilder = new SqlCommandBuilder(thisAdapter); // DataSet thisdataset = new DataSet(); // thisAdapter.Fill(thisdataset, "Doctors"); // DataColumn[] keys = new DataColumn[1]; keys[0] = thisdataset.Tables["Doctors"].Columns["DoctorID"]; thisdataset.Tables["Doctors"].PrimaryKey = keys; foreach (DataRow FindtheRow in thisdataset.Tables["Doctors"].Rows) { if (FindtheRow["DoctorID"].ToString() == comboBoxdeletedoctor.Text) { FindtheRow.Delete(); FindtheRow.AcceptChanges(); thisAdapter.Update(thisdataset, "Doctors"); } thisConnection.Close(); } Administration main = new Administration(); main.Visible = true; main.Activate(); textBoxFN.Clear(); textBoxNAme.Clear(); this.Hide(); }