PC Review


Reply
Thread Tools Rate Thread

Check user input data exist in database: ERROR

 
 
Jack
Guest
Posts: n/a
 
      17th Jul 2007
Dim retVal As Boolean = False
Dim cnSQL As SqlConnection
Dim cmSQL As SqlCommand
Dim strSQL As String

strSQL = "Select * From Table_Contacts where EmailAddress = '" &
txtEmail.Text & "' OR Name = '" & txtName.Text & "';"
cnSQL = New SqlConnection(thisConnection)
cnSQL.Open()

cmSQL = New SqlCommand(strSQL, cnSQL)
Dim reader As SqlDataReader = cmSQL.ExecuteReader()

If Not reader.HasRows Then
retVal = False
MessageBox.Show("No Record")
Else
MessageBox.Show(" already exists!", " ", MessageBoxButtons.OK,
MessageBoxIcon.Error)
retVal = True
End If

cnSQL.Close()
cmSQL.Dispose()
cnSQL.Dispose()
retVal = True


Can someone help me with this?
I'm keep getting "already exist" even there is no matching record in the
database.

- Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HID Non-User Input Data Filter-------Error Bob Windows XP Hardware 1 3rd Apr 2011 01:56 PM
How to check if Work order exist through a query to the database MNJoe Microsoft Access VBA Modules 2 27th Jan 2009 05:56 PM
Forms: Comparing user input on a form to data in a database chrisdsax Microsoft Frontpage 1 11th Jan 2008 09:15 AM
Check user input =?Utf-8?B?anZpY2hheWFub25kYUBob3RtYWlsLmNvbQ==?= Microsoft Excel Programming 3 24th Mar 2006 09:04 AM
check if exist user part of domain acct logon script =?Utf-8?B?Sm9obiBWdQ==?= Microsoft Windows 2000 Networking 1 17th Nov 2003 09:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:46 AM.