So heres my problem:
I have a datagrid w/ 5 columns(ID, firstname, lastname, Membership, Date). My app takes a 5 digit number from the user and with that number populates my datagrid with the members information. My BIGGEST problem is trying to check to see if the member is already in the datagrid or not. Here is my validating code:
private void findMember()
{
table = ds.Tables[0];
//foreach datagridRow in datagrid
foreach (DataGridViewRow row in dataGridView1.Rows)
{
// if not a new row
if (!row.IsNewRow) //checking for a new row
{
string memberDGV = dataGridView1[3, row.Index].Value.ToString();
// foreach dataRow in dataTable
foreach (DataRow dr in table.Rows)
{
string memberDT = dr[3].ToString();
if (memberDGV == memberDT)
{
// MessageBox.Show("Member is in dgc");
insertDate();
}
if (memberDGV != memberDT)
{
// MessageBox.Show("member is not in here");
insertMember();
insertDate();
}
}
}
}
}
The problem is that memberDGV & memberDT variables will always come up as the same value when im debugging and stepping through the code. The code will work the first time I try inputting a new member into my datagrid(It will insert the user into my sql table and display my table through the datagrid)However, once I try inserting another new member, it will replicate that members info multiple times.
Can anyone help?!!??!?!?!?! Much appreciation.