Link to home
Start Free TrialLog in
Avatar of cuconsortium
cuconsortiumFlag for United States of America

asked on

Syntax error converting varchar to data type int

Dear experts,

  I'm creating a search and result page in ASP using Dreamweaver MX 2004.

The URL Paramter passed from the search.asp page is a varchar datatype.  

I attempt to create a recordset in result.asp page using Dreamweaver MX 2004's Add Recordset Server Beheavior and add a Variable in Variables list as follow:

Name           Default Value     Run-Time Value      
-------          ----------------    ---------------------
srchParm     3ABC12345        Request.QueryString("txt_search")


When I press Test button, Dreamweaver MX 2004 returns an error message: Syntax error converting varchar "3ABC12345" to data type int


My Question:

Why would Dreamweaver MX 2004 want to convert the value of the variable to int datatype??
When I leave Default Value blank, DW MX 2004 returns an error message saying the default value is missing and the recordset cannot be saved.

I need to be able to show the search result base on the searching parameter on the search.asp page.  How do I get it to work?

Thank you very much!!!
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

please show the sql query / procedure code that you use.
the error is in there.

typically, it happens when you are trying to append a varchar and a numerical data. sql server gives priority to the numerical data (why, i don't know, but it's like that), so you have to explicitely convert the numerical value to varchar:

this will fail with your error:
select 'ABC' + 1

this will work:
select 'ABC' + convert(1 as varchar)

I would prefer the PAQ with no points refunded, as the answer has been given IMHO... despite of the missing feedback of the questionner :-(
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial