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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top