Click to See Complete Forum and Search --> : Verification


Navi
04-20-2008, 12:02 PM
Hi expert! How to get the code like this in VB.net? After the data is submitted to the Time1 field of the database, if the there is data in Time1, when the user click the button, it will shows erros "The data is submitted already!".
Here is my code and any help will be greatly appreciated!


Sub Do_test(sender as Object, e as EventArgs)


Dim CountTime as Int32 = 0


strSQL="Select count(*) from C WHERE IDEmployee= '" & currEmpNumber & "' and serverDate = '" & currServerDate & "'"
Call OpenDB()

Dim myCommand3 As New odbcCommand(strSQL, connTemp)
CountTime = myCommand3.ExecuteScalar()
Call CloseDB()


If CountTime = 0 Then

labelMessage.text = "* Error! You did not Enter the data! "

else

If CountTime > 0 Then

strSQL="UPDATE C SET Out1 = '" & currServerTime & "' WHERE IDEmployee= '" & currEmpNumber & "'

Call OpenDB()

call InsertUpdate(strSQL)
Call CloseDB()



// Anyway to add some coding here to test if the data (out1) does exist and if it does, promp an error message



End IF
end if
end if

chazzy
04-20-2008, 12:34 PM
i'm not quite sure what you mean. do you want to check to see if CountTime > 0? already doing that. ?

Navi
04-20-2008, 11:13 PM
Thanks for your response! Actually I have four buttons and it works only for the first button and rest of the button doesn't work at all. The four fields are time, time1, time2, and time3. Thanks for your advice!

chazzy
04-21-2008, 01:02 AM
I'm really seeing a huge disjoint in your code. What you so far posted doesn't do any checks against data that was entered in the form, not the fields you entered at least. it looks like it modifies a label's text, and reads from the fields: currEmpNumber & currServerDate, nothing at all with time, time1, time2, and time3. Are all of these actually buttons or do you mean text fields? where do you call do_test from? why don't you have do_test take in the arguments, and then you can loop through each of time, time1,time2, and time3?

Navi
04-21-2008, 11:48 PM
Thanks chazzy! Sorry, Out1 not Time1. Based on your suggestions, how to fix the coding? Thanks!