【问题标题】:Team Developer 2005.1 - Into Variable Always EmptyTeam Developer 2005.1 - 变量始终为空
【发布时间】:2018-01-18 02:06:08
【问题描述】:

我们正在处理基于 Team Developer 2005.1 的遗留代码

有一个类似的查询

  !!CB!! 70
Set sSqlCommand = '
            SELECT  name, value
            INTO    :sName, :sValue
            FROM    av_system_settings
            WHERE   name LIKE \'Company_\%\''
If NOT SqlPrepareAndExecute( hSqlMain, sSqlCommand )
    Return FALSE
Loop
    If SqlFetchNext( hSqlMain, nFetch )
    ...

这里 into 变量 :sName, :sValue 是字符串,但它总是有空值,尽管记录已通过 SqlFetchNext 正确循环

其他地方的 into 变量都可以。只是不在一个地方工作。

在这方面已经用尽了大脑......有什么想法吗?伙计们:)

【问题讨论】:

    标签: guptateamdeveloper


    【解决方案1】:
    1. 对于测试,您可以使用 SqlImmediate(sSqlCommand ) 代替 sqlprepareandexecute( )。如果 sName 和 sValue 在之后有值 执行 sqlImmediate 意味着 sql 工作正常。
    2. 确保 SqlConnect() 函数返回真值。如果它返回 false,则确保数据库信用是正确的。
    3. 如果 sValue 变量需要保存 Long 数据,请查看 SqlSetLongBindDatatype ( ) 函数。

    4. 检查 sql 句柄 hsqlMain 的值,如果它是正值或正值,则表示句柄连接正确。除此以外 如果句柄值为空或零,则表示句柄未连接。

    5. 尝试使用 SqlFetchRow ( hsqlMain, nRow, nFetch ) 并将 nRow 的值加 1 直到函数返回 false 或 nFetch 的值变为 FETCH_EOF。

      Set nRow = 0 While (TRUE) If not SqlFetchRow( hsqlMain, nRow, nFetch ) Break Set nRow = nRow + 1

    【讨论】:

    • 原来问题是由 case #3 in answer引起的:data field is long than 254 but String variable type were used with INTO... 将它们更改为 Long String ,它现在正在工作。谢谢!
    • 很高兴它有帮助!请考虑接受最佳答案。
    【解决方案2】:

    在 SqlFetchNext 之后检查 nFetch 以确保找到记录。

    如果 nFetch = FETCH_Ok ,则找到一条记录。 因此,请尝试在 SqlFetchNext 之前调用 SqlVarSetup(hSqlMain) ,因此 into vars 具有上下文。 还可以尝试限定 into vars,例如:hWndForm.frmTest.sName .

    如果 nFetch = FETCH_EOF ,则没有找到记录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-05
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      • 2021-07-07
      相关资源
      最近更新 更多