views:

47

answers:

1

I have a strange one here..

I create a recordset using Classic ASP

  Set rs = server.CreateObject("ADODB.Recordset")            
  rs.ActiveConnection = g_conn
        rs.CursorLocation=3                 '   adUseClient
        rs.LockType= 3                      '   adLockBatchOptimistic  
        on error resume next
        rs.Open strQuery    
        rs.activeConnection = nothing     
        on error goto 0

All works good, recordset is created as expected. I now want to update the text only fields in the recordset with a new value...

            do while not rs.eof 
                for each fld in rs.fields
                    if ( instr(",129,130,201,202,203,",","+cStr(rtrim(fld.type))+",")>0) then
                        theStr = g_VBPM.PMDecode(rs(fld.name))
                        'rs(fld.name).value= ucase(rs(fld.name))     ' works
                        rs(fld.name).value= trim(theStr)             ' does not work
                    end if                            
                next                        
                rs.movenext
            loop                    

When I replace the field value with the uppercase text of the string, it works. The recordset reflects uppercase versions of the field content. However, when I replace it with the string I returned from my C# DLL, no error message is returned, but the field value in the recordset is not changed. The return value from the C# code contains the right thing, and I can see it if I do response.write. However, when I attempt to put that string into the disconnected record set, it doesn't work.. No error at all

Anyone ever see this type of behavior? Any ideas? The C# code does work, I use it and other places in the application.

+1  A: 

The problem took some digging: The C# function was returning a UTF-8 string. The ASP code did set the codepage to 65001 to deal with UTF-8, which is why the variable showed the proper value. However, certain field types within the recordset cannot hold UTF-8 data. In addition, the ON ERROR handling on the ASP code did not catch the error, (Err.number was zero). but the underlying connection did report an error.

Once I adapt the code to raise an error if ERR.NUMBER or the Connection had an error, the problem became apparent and I was able to develop a work around...

Thanks to everyone who took the time to look at my problem, I appreciate it

Sparky