0
New Here
,
/t5/dreamweaver-discussions/sql-convert-data-type-from-varchar-to-money-asp-vb-sql/td-p/29345
Oct 10, 2006
Oct 10, 2006
Copy link to clipboard
Copied
Hi,
I'm trying to do a simple search form that takes a value for a max imum price from a text-field in a form, which is then passed to a catalogue page. On this page I have a select query that includes a where condition for price less than the value of the query string.
A simplified version of the query is:
"SELECT * from table where price < 'varPrice' "
When I run this I get an error saying
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type money to varchar is not allowed. Use the CONVERT function to run this query.
I've googled this a fair bit and can't really find what I need to get me started - anyone able to point me in the right direction?
Thank you very much,
I'm trying to do a simple search form that takes a value for a max imum price from a text-field in a form, which is then passed to a catalogue page. On this page I have a select query that includes a where condition for price less than the value of the query string.
A simplified version of the query is:
"SELECT * from table where price < 'varPrice' "
When I run this I get an error saying
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Implicit conversion from data type money to varchar is not allowed. Use the CONVERT function to run this query.
I've googled this a fair bit and can't really find what I need to get me started - anyone able to point me in the right direction?
Thank you very much,
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
LEGEND
,
Oct 10, 2006
Oct 10, 2006
You're comparing price (money) to 'varPrice' (text), and an
implicit
conversion between those two types is not allowed. You have to explicitly
CAST or CONVERT the column.
In your case, I imagine you don't really mean for varPrice to be text. Lose
the quotes and it will be considered a number.
"tedstar" <webforumsuser@macromedia.com> wrote in message
news:eggr3h$old$1@forums.macromedia.com...
> "SELECT * from table where price < 'varPrice' "
conversion between those two types is not allowed. You have to explicitly
CAST or CONVERT the column.
In your case, I imagine you don't really mean for varPrice to be text. Lose
the quotes and it will be considered a number.
"tedstar" <webforumsuser@macromedia.com> wrote in message
news:eggr3h$old$1@forums.macromedia.com...
> "SELECT * from table where price < 'varPrice' "
LEGEND
,
/t5/dreamweaver-discussions/sql-convert-data-type-from-varchar-to-money-asp-vb-sql/m-p/29346#M108762
Oct 10, 2006
Oct 10, 2006
Copy link to clipboard
Copied
You're comparing price (money) to 'varPrice' (text), and an
implicit
conversion between those two types is not allowed. You have to explicitly
CAST or CONVERT the column.
In your case, I imagine you don't really mean for varPrice to be text. Lose
the quotes and it will be considered a number.
"tedstar" <webforumsuser@macromedia.com> wrote in message
news:eggr3h$old$1@forums.macromedia.com...
> "SELECT * from table where price < 'varPrice' "
conversion between those two types is not allowed. You have to explicitly
CAST or CONVERT the column.
In your case, I imagine you don't really mean for varPrice to be text. Lose
the quotes and it will be considered a number.
"tedstar" <webforumsuser@macromedia.com> wrote in message
news:eggr3h$old$1@forums.macromedia.com...
> "SELECT * from table where price < 'varPrice' "
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
tedstar
AUTHOR
New Here
,
LATEST
/t5/dreamweaver-discussions/sql-convert-data-type-from-varchar-to-money-asp-vb-sql/m-p/29348#M108764
Oct 10, 2006
Oct 10, 2006
Copy link to clipboard
Copied
Thank you both very much for your help. Fantastic to get help
so quickly.
cheers. Ed
cheers. Ed
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/dreamweaver-discussions/sql-convert-data-type-from-varchar-to-money-asp-vb-sql/m-p/29347#M108763
Oct 10, 2006
Oct 10, 2006
Copy link to clipboard
Copied
> A simplified version of the query is:
>
> "SELECT * from table where price < 'varPrice' "
If price is an integer, it can't be greater than or less than a string.
You need to compare apples to apples.
I'd do this:
dim varPrice as integer
varPrice = cint(yourFormField.text)
"SELECT * from table where price <" & varPrice
Though note that you shouldn't be passing user-input data into a SQL string
like that. Look into use parameterized SQL to handle that.
-Darrel
>
> "SELECT * from table where price < 'varPrice' "
If price is an integer, it can't be greater than or less than a string.
You need to compare apples to apples.
I'd do this:
dim varPrice as integer
varPrice = cint(yourFormField.text)
"SELECT * from table where price <" & varPrice
Though note that you shouldn't be passing user-input data into a SQL string
like that. Look into use parameterized SQL to handle that.
-Darrel
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

