I am having a problem that dtAsia.rows.count>0 doesn't count at all. All I want to do is tell the user that their username already exists in the game but I'm having a bad time now because for example: I entered a valid username and its success... I entered an invalid username and got the CATCH part of this code.. So if i entered a valid username again. I still got the CATCH part of the code until the end even if I enter valid or invalid username still got the CATCH part. What did I do wrong here? I will really appreciate answers. Thank you

If (dtAsia.Rows.Count > 0) Then ' wont work
            MsgBox("Username: " & Trim(txtUsername.Text) & " is already exist.", MsgBoxStyle.OkOnly, "Message :")
        Else
            Try
                Call open_conn()
                SqlComm.Connection = conn
                SqlComm.CommandText = "Select * from Personal_Information"
                SqlComm.CommandText = "INSERT INTO Personal_Information(Username) values('" & Trim(txtUsername.Text) & "')
                SqlComm.ExecuteNonQuery()
                Call close_conn()
                MessageBox.Show("Account registered successfully!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Call Updater()
            Catch ex As Exception 'Here is the CATCH PART
                MsgBox("error " & Trim(txtUsername.Text) & " is already exist.", MsgBoxStyle.OkOnly, "Message :")
            End Try
        End If

if possible can you please attach the project here.....

I guess that dtAsia is a dataset you've filled using the username as a criteria, so 0 rows means you've got to insert the user in personal_information.
unfortunately you are not providing what goes on when filling the dtAsia, so my only suggestion would be to step through the code at debug and see where the jump to catch happens and then msgbox yourself the exception to see what goes wrong.

PS: I don't understand why you are first setting the command to a select and then changing it to an insert, but this couldn't be the problem.

oh... I already this figured out.. I removed the TRY statement to see the exact error.. and i got it.. thanks anyways

commented: thats the learning process +5

If your problem is solved make the thread as solved....

Dim sqlcon As New SqlClient.SqlConnection(My.Settings.CLSHWSETAConnectionString.ToString)
Dim objCom As New SqlClient.SqlCommand(strquery, sqlcon)
sqlcon.Open()

Now you know where the error is, try solving it and if you still encounter further problems, you can surely get your answer here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.