经典 ASP 记录集不允许字段更新

发布于 2024-09-25 18:49:16 字数 1293 浏览 6 评论 0原文

我这里有一个奇怪的..

我使用经典 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

一切正常,记录集按预期创建。我现在想用新值更新记录集中的纯文本字段...

            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                    

当我用字符串的大写文本替换字段值时,它起作用了。记录集反映字段内容的大写版本。但是,当我将其替换为从 C# DLL 返回的字符串时,不会返回任何错误消息,但记录集中的字段值不会更改。 C# 代码的返回值包含正确的内容,如果我执行response.write,我就可以看到它。但是,当我尝试将该字符串放入断开连接的记录集中时,它不起作用。根本没有错误

有人见过这种类型的行为吗?有什么想法吗? C# 代码确实有效,我在应用程序中的其他地方使用了它。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巷雨优美回忆 2024-10-02 18:49:16

这个问题需要一些挖掘:C# 函数返回一个 UTF-8 字符串。 ASP 代码确实将代码页设置为 65001 来处理 UTF-8,这就是变量显示正确值的原因。但是,记录集中的某些字段类型无法保存 UTF-8 数据。此外,ASP 代码上的 ON ERROR 处理没有捕获错误(Err.number 为零)。但底层连接确实报错。

一旦我调整代码以在 ERR.NUMBER 或连接出现错误时引发错误,问题就变得显而易见,并且我能够开发解决方案......

感谢每个花时间查看我的问题的人,我欣赏它

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文