How to check if email id already exist in db using vb6

r.Open " select count(*) from login where username = '" & Text1.Text & " ' ", c, 3, 3
If Count > 0 Then
MsgBox " already exist "
Else
MsgBox "valid"
End If
r.Close

plese help this cod always show only 'already exist' msg.

I would say that you are checking the rowcount returned from the select statement, rather than the actual value of count(*) that is returned.

If you get a hit on that username, you'll get one row returned, and the value of count(*) will be 1.

If you DON'T get a hit on that username, you'll still get one row returned, and the value of count(*) will be zero.

But, in both cases, the rowcount will still be one, therefore your message will always be "already exist".

Hope that helps!

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.