I want to display an error if the employee had an account already

Here is my code:

 rs.Open("Select * from tbl_emp_security WHERE Emp_ID='" & EmpID_account.Text & "'", con)
        If EmpID_account.Text = LVempaccount.Items(rs(0).Value) Then
            MsgBox("this employee have existing account")
        Else
            user_account.Text = "Emp" & Lname_account.Text
            passRandom()
    End If

Is if the employee try to add an account and if he had already... the messagebox will appear but if none. It proceeds to the next line..

empid_accout.text is the textbox that I am comparing to the first item on table.

lvempaccount.tems(rs(0),value) is the item that on the 1st column the employee id on the table

Answers


I would rewrite your code as follows

Hope it helps

Dim OutDs AS new Dataset
OutDS = ("Select * from tbl_emp_security WHERE Emp_ID='" & EmpID_account.Text & "'", con)

If OutDs isnot nothing andalso OutDs.Table.Rows.Count > 0  Then
            MsgBox("this employee have existing account")
        Else
            user_account.Text = "Emp" & Lname_account.Text
            passRandom()
    End If

If the Select Query returns a dataset , it means it has value so i used this way..!


Need Your Help

my app crashed after received memory warning while uploading data

iphone objective-c cocoa-touch cocoa asihttprequest

Each time I will upload a slice of data about 2Mb by calling the following method.

Deserialize dynamic fields with GSON into POJO

java json gson

I've tried so many ways, but without success to parse this Json to a Java Object using Gson library: