hey guys me again.
got a little problem with the code finding the table with the index of 0 (zero)
i dont see the problem my self as i am using only one table.
this is the code for my update function:
private void UpdateBTN_Click(object sender, EventArgs e)
{
using (conn)
{
da.UpdateCommand = new SqlCommand("UPDATE Book SET Title = @title, AuthorFirstName = @authorFirstName, AuthorSurname = @authorsurname, AquisitionDate = @aquisitiondate, PublisherName = @publishername,
PublisherCity = @publishercity, PublishingDate = @publishingdate,
ISBN = @isbn, DDClassification = @ddclassification WHERE BookID = @ID", conn);
da.UpdateCommand.Parameters.Add("@title", SqlDbType.VarChar).Value = titleTB.Text;
da.UpdateCommand.Parameters.Add("@authorFirstName", SqlDbType.VarChar).Value = authorFirstNameTB.Text;
da.UpdateCommand.Parameters.Add("@authorsurname", SqlDbType.VarChar).Value = authorSurNameTB.Text;
da.UpdateCommand.Parameters.Add("@aquisitiondate", SqlDbType.Date).Value = aquisitionDateTB.Text.ToString();
da.UpdateCommand.Parameters.Add("@publishername", SqlDbType.VarChar).Value = publisherNameTB.Text;
da.UpdateCommand.Parameters.Add("@publishercity", SqlDbType.VarChar).Value = publisherCityTB.Text;
da.UpdateCommand.Parameters.Add("@publishingdate", SqlDbType.Date).Value = publishingDateTB.Text.ToString();
da.UpdateCommand.Parameters.Add("@isbn", SqlDbType.VarChar).Value = ISBNTB.Text;
da.UpdateCommand.Parameters.Add("@ddclassification", SqlDbType.VarChar).Value = DDClassificationTB.Text;
da.UpdateCommand.Parameters.Add("@ID", SqlDbType.Int).Value = ds.Tables[0].Rows[tblNamesBS.Position][0];
conn.Open();
da.UpdateCommand.ExecuteNonQuery();
}
}
error is on last update parameter, any idea why it is throwing this exception?
message is:
IndexOutOfRangeException was unhandled
Cannot find table 0.
Regards
Matt.