Error conversion in asp page calling SQL

  • Thread starter Thread starter axapta
  • Start date Start date
A

axapta

Hi Group,
I get the following error.
Syntax error converting the varchar value ' WHERE application.RegNo =
148997' to a column of data type int.

I've got an asp.net form which allows the user enters in some criteria and
search. The datatype field for regno is int. I've used the following in my
page and my sql:

If Trim(txtRegNo.Text) <> "" Then
strWhere = strWhere & "application.RegNo = '%"
& txtRegNo.Text & "%'"
blnElementAdded = True
blnSearchMainOnly = True
End If



How can I get over this problem.

TIA
 
If the field type in the database is int don't put the value in quotes (and
%s) in the sql

e.g.

If Trim(txtRegNo.Text) <> "" Then
strWhere = strWhere & "application.RegNo = " & txtRegNo.Text &
blnElementAdded = True
blnSearchMainOnly = True
End If

Kind regards

Rob
 
Back
Top