I need some help.
I am writing an application in VB .net and have run into problem and need some help. I have a database that stores the evaluation of some clients. The evaluation is done on a cycle basis, each cycle has 7 day and there are 6 cycles. The thing is the days are continuous for example cycle 1 has day one to 7 but cycle 2 begins on day 8 and cycle 3 on day 15 and so on. The problem is I do want duplicate records happening for any individual. Every individual has an id. So how do I prevent duplicate record for anyone happening? For example for person A prevent Cycle 2 evaluation 9 from being entered twice.
This is how I attempted to do this but it’s not working the way I want. I would like a message to popup if that record already exists.
While cycle.Read
If String.Compare(cycle("ID").ToString.ToLower, Me.TextBox1.Text.ToLower) = 0 Then
'ID number is found
'Compare CycleNum
If String.Compare(cycle("CycleNum").ToString, Me.TextBox5.Text) = 0 Then
Me.LB2_Message.Text = "This DOR number already exist for this recruit"
cycle.Close()
Exit Sub
Else 'Valid ID name and CycleNum
'comm.CommandText = "INSERT INTO TEXT_REPORT(ID,FTO,R_Date,Most,Least,Additional,Week,CycleNum) VALUES('" + Me.TextBox1.Text + "','" + Me.TextBox2.Text + "','" + Me.TextBox3.Text + "','" + Me.txtMost.Text.Replace("'", "''") + "','" + Me.txtLeast.Text.Replace("'", "''") + "','" + Me.txtAdd.Text.Replace("'", "''") + "','" + Me.TextBox4.Text + "','" + Me.TextBox5.Text + "')"
Session.Add("ID", cycle("ID").ToString)
Session.Add("CycleNum", cycle("CycleNum"))
Exit Sub
End If
End If
End While
cycle.Close()