I have a function which I wrote to validate it against SQL Server Db and this value which should be validated is a scanned barcode value ... this works fine when I scan a partnumber it checks this partnumber against the db and works correctly but not for the other partnumber ... Is there any specific reason for this as I am a newbie to Sql Server as well to VB . Anyone's help would be greatly appreciated and below is the function code
Function validatepartNo(strpartnumber As String) As Boolean
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim strSQL As String
cnn = SQLDB_CONN_STRING
cnn.CommandTimeout = 300 ' added
' MsgBox strpartnumber
strSQL = "Select count(*) from tblParts Where UPN = '" & Trim(strpartnumber) & "'"
rst.Open strSQL, cnn
If Trim(rst(0).Value = 0) Then
validatepartNo = False
MsgBox "Partno not existing in tblParts table", vbOKOnly, " Invalid Partno"
validatepartNo = True