Jump to content

Data type mismatch


Splurd

Recommended Posts

Anyway, I have a problem, and for reference I am using asp.I have a database(duh) and I am selecting values from it using a sorta dynamic table, Instead of making a page to display data for all the diffrent tables / sitautions etc, I made a table which takes in values from forms and displays data.The problem is, my condition statement. I have some statements which are string, and some which are numbers, so the quotation marks screw me up.And I cant check if the value can be converted to string, because I have some values in the DB which are all numbers, but stored as text. (they want the 0005 look.)Any advice?

Link to comment
Share on other sites

You can use commands like CONVERT or CAST for string to integer conversion....http://www.experts-exchange.com/Databases/Q_20646601.html

This requires me to register and pay money.The logic of the page is like this,
<form  method="post" action="displaytb2.asp"><input name="table" type="hidden" value="Warrenty2_tb" >Select an option<select name="option">	<option value="all" selected >View All Warrenties</option>	<option value="search">Search</option></select><br>Conditions for search:<br>Look in :<select name="field">	<option value='NA' selected>-Select one-</option>	<option value="Warrenty_ID" >Warrenty No</option>	<option value="UF_id" >UF id</option>	<option value="Cus_nam" >Customer name</option>	<option value="Cus_age" >Customer age</option>	<option value="Cus_contact" >Customer Contact number</option>	<option value="Cus_email" >Customer Email</option>	<option value="Cartridge" >Cartridge</option>	<option value="Weight" >Weight</option></select><select name="cond">	<option value=' = ' selected>Equals to</option>	<option value=' <> '>Not equals</option>	<option value=' > '>Greater than</option>	<option value=' < '>Less than</option>	<option value=' LIKE '>Search</option></select>Search for :<input name="searchvar" type="text" value="Enter Seach value here"><br><input type="submit" value="hahahah"></form>

Then in the displaytb2.asp

if Request.Form("option") = "all" then 	T_SQL = "SELECT * FROM " & Request.Form("table")elseif Request.Form("option") = "search" then	T_SQL = "SELECT * FROM " & Request.Form("table") & " WHERE " & Request.Form("table") & "." & Request.Form("field") & Request.Form("cond")	if Request.Form("cond") = " LIKE " then T_SQL = T_SQL & "'%" & Request.Form("searchvar") & "%'"	else T_SQL = T_SQL & "'" & Request.Form("searchvar") & "'" end ifend if

This works fine if all my values are text, but if they are numbers, it gets the error.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...