Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type mismatch error

Status
Not open for further replies.

penguinspeaks

Technical User
Nov 13, 2002
234
US
Hello all.

I am getting a mismatch and not sure as to why.

Code:
id = request.form("id")

v_their_damaged = request.form("their_damaged")
v_their_good = request.form("their_good")
v_their_flawless = request.form("their_flawless")
v_our_damaged = request.form("our_damaged")
v_us_good = request.form("us_good")
v_us_flawless = request.form("us_flawless") 

set check1 = conn.execute("select id, usdamaged_, usused, usflawless from pricing where id = "&id&"")
	var1 = check1.fields.item("usdamaged_").value
	var2 = check1.fields.item("usused").value
	var3 = check1.fields.item("usflawless").value
	
		if v_their_damaged <> var1 or v_their_good <> var2 or v_their_flawless <> var3 then
			strSQL = "update pricing set usdamaged_ = "&v_our_damaged&" where id = "&id&""
			conn.execute (strSQL)
			
			strSQL = "update pricing set usused = "&v_us_good&" where id = "&id&""
			conn.execute (strSQL)
			
			strSQL = "update pricing set usflawless = "&v_us_flawless&" where id = "&id&""
			conn.execute (strSQL)

		else

the database fields for all of these are decimal 5,2. the form these are coming from are from the same table.
Since they are pulled from the same table and the fields are all decimal 5,2 why woulod this be happening?
 
Which line gets the error? What are the values of the variables at the time of the error?

You can add some error trapping, like this:
Code:
strSQL = "update pricing set usdamaged_ = "&v_our_damaged&" where id = "&id&""
[COLOR=blue]On Error Resume Next[/color]
conn.execute (strSQL)
[COLOR=blue]If Err.Number <> 0 Then 
   response.write "Err#" & Err.Number & ": " & Err.Description & "<br>" & strSQL
   response.end
End If
On Error Goto 0[/color]
 
SORRY FOR NOT POSTING THE LINE:

Code:
if v_their_damaged <> var1 or v_their_good <> var2 or v_their_flawless <> var3 then

I will add the trapping as you suggested.

What I did to make this work is format the numbers to a two digit decimal for all of the numbers once I called them from the DB table.
I am not sure why this was necessary but it did work. But thanks for the reply and the idea to trap the error.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top