Error conversion in asp page calling SQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • axapta

    Error conversion in asp page calling SQL

    Hi Group,
    I get the following error.
    Syntax error converting the varchar value ' WHERE application.Reg No =
    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.T ext) <"" Then
    strWhere = strWhere & "application.Re gNo = '%"
    & txtRegNo.Text & "%'"
    blnElementAdded = True
    blnSearchMainOn ly = True
    End If



    How can I get over this problem.

    TIA

  • Rob Blackmore

    #2
    Re: Error conversion in asp page calling SQL

    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.T ext) <"" Then
    strWhere = strWhere & "application.Re gNo = " & txtRegNo.Text &
    blnElementAdded = True
    blnSearchMainOn ly = True
    End If

    Kind regards

    Rob



    "axapta" <jas.jackie@gma il.comwrote in message
    news:5F639943-2771-47B2-A4E6-2B58DAF9AF47@mi crosoft.com...
    Hi Group,
    I get the following error.
    Syntax error converting the varchar value ' WHERE application.Reg No =
    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.T ext) <"" Then
    strWhere = strWhere & "application.Re gNo = '%"
    & txtRegNo.Text & "%'"
    blnElementAdded = True
    blnSearchMainOn ly = True
    End If
    >
    >
    >
    How can I get over this problem.
    >
    TIA

    Comment

    Working...