开发者

Classic ASP, Provider: Type mismatch Error

I have the following ASP code below which is used within a import from a .csv file. I am getting the error on line

rs_add_pg_asset_attr("level_3_integer_attribute_description") = rs_get_costs("sp_import_pg_attribute_value")

I'm guessing the code is trying to set 2 columns in two different recordsets to be equal to the same thing? Correct me if I'm wrong. The data in level_3_integer_attribute_description is type decimal(13,3), NULL and the data in sp_import_pg_attribute_value is a whole range of different values type varchar(255), NULL.

I cannot work out why this is failing.

str_get_pg_attribute_id_sql = "SELECT * FROM tbl_level_3_cbs_attribute WHERE level_3_cbs_attribute_description = '" & rs_get_costs("sp_import_pg_attribute") & "'"
str_get_pg_attribute_id_sql = str_get_pg_attribute_id_sql & " AND level_3_cbs_id = " & int_level_3_id
rs_get_pg_attribute_id.Open str_get_pg_attribute_id_sql, dbConnection, 3
if rs_get_pg_attribute_id.RecordCount <> 0 then

   ''//Does the attribute already exist?
   str_get_pg_attribute_sql = "SELECT * FROM tbl_asset_level_3_attribute_link WHERE "
   str_get_pg_attribute_sql = str_get_pg_attribute_sql & "level_3_cbs_attribute_id = " & rs_get_pg_attribute_id("level_3_cbs_attribute_id") & " AND asset_level_3_id = " & int_pg_asset_id

   rs_get_pg_attribute.Open str_get_pg_attribute_sql, dbConnection, 3
   if rs_get_pg_attribute.RecordCount = 0 then
      ''//No, add the attribute record
      sqlString="select top 1 * from tbl_asset_le开发者_开发知识库vel_3_attribute_link"
      rs_add_pg_asset_attr.Open sqlString, dbConnection, adOpenKeyset, adLockOptimistic
      rs_add_pg_asset_attr.AddNew
      rs_add_pg_asset_attr("level_3_cbs_attribute_id") = rs_get_pg_attribute_id("level_3_cbs_attribute_id")  
      rs_add_pg_asset_attr("asset_level_3_id") = int_pg_asset_id
      if rs_get_pg_attribute_id("level_3_cbs_attribute_type") = "I" then
          rs_add_pg_asset_attr("level_3_integer_attribute_description") = rs_get_costs("sp_import_pg_attribute_value")
      else 
          rs_add_pg_asset_attr("level_3_string_attribute_description") = rs_get_costs("sp_import_pg_attribute_value")
      end if


Are you sure that level_3_integer_attribute_description is an existing field name, no typo error anywhere ?

If so, is the data you want to put into this decimal value, a correct string representation of a floating value ? No problems with decimal points and comma's ?


Since the error is a Type Mismatch error, you probably have a type mismatch error :)

Try this:

rs_add_pg_asset_attr("level_3_integer_attribute_description") = _
                       tryCDbl( rs_get_costs("sp_import_pg_attribute_value"))

and then:

function tryCDbl( something )
    dim retval
    retval = 0 ''// fallback

    on error resume next
    if isNumeric( something ) then
       retval = cdbl( something) 
    end if

    tryCDbl = retval
end function


We found the answer to this question. The problem was the Import was trying to assign a blank space into a decimal column. Thanks for your help. I'm stuck on something else now!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜