如题,我想以数字作为字段名,例如:20.0

解决方案 »

  1.   

    想想也不知道不行了
    假设让你把字段名变成20.0了,现在写一个查询语句 where条件为 20.0<21
    你让计算机如何判断?
      

  2.   

    设三个字段
    id   f90   f60
    20 -6.0  -5.0 
    30 -5.0  -4.0
      

  3.   

    谢谢各位!还有一个问题:一个二维数组
      id   f90   f60
     20   -5.0   -4.0
    这是数据库的存储方式,现在字段名“f90”"f60" 可以用一个变量存储strname,当id=20时,如果strname=f90则取-5.0,"f60"则取-4.0
    rst.open"select * from a1 where id="20" ",
    value=rst.fields![strname]
    提示找不着字段,怎么办
      

  4.   

    !后面不能用变量
    value=rst.fields(strname).Value
      

  5.   

    rst.open"select " & strname & " as myvalue from a1 where id='20' "
     value=rst.fields!myvalue
      

  6.   

    为什么到最后一个值打不出来
    for i=0 to 9
    rst.open"select " & strname&" as myvalue from a1 where id=' " & array(i) &"'"
    next 
    前面的9个数都能打出来,一到第10个数就显示rst.fields!myvalue=null
      

  7.   

    因为数据为 null 造成的,把rst.fields!myvalue 修改成 rst.fields!myvalue & ""
      

  8.   

    不是数据库的数据为空,对应的条件有相应的取值,但是经过那个sql语句判断后,就认为数据库为空。
    我把循环写到上面一个8,第9个数单独像这样再写一段,数据就能调出来。
      

  9.   

        Set rstForce = New ADODB.Recordset
        For i = 0 To 9
           strAlterDegree(i) = "": strNextDegree(i) = ""
           If Right(txtRm(i).Text, 1) <> "0" And Right(txtRm(i).Text, 1) <> "" Then
            rstForce.Open "select  " & strLp & " as myValue from DFieldForce where id='" & strZhengShu(i) & "'", Myconn, adOpenKeyset, adLockReadOnly
            If Not rstForce.EOF Then
    '           strAlterDegree(i) = rstForce.Fields!myValue & ""
               strAlterDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue])
               If strAlterDegree(i) = "" Then GoTo continue
            End If
            rstForce.Close
            rstForce.Open "select " & strLp & " as myValue from DFieldForce where id='" & Val(strZhengShu(i)) + 1 & "'", Myconn, adOpenKeyset, adLockReadOnly
            If Not rstForce.EOF Then
               strNextDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue])
               If strNextDegree(i) = "" Then GoTo continue
            End If
            rstForce.Close
    continue:   Next i
      

  10.   

    给的代码有问题,if 和 end if 不能对应
      

  11.   

        Set rstForce = New ADODB.Recordset 
        For i = 0 To 9 
          strAlterDegree(i) = "": strNextDegree(i) = "" 
          If Right(txtRm(i).Text, 1) <> "0" And Right(txtRm(i).Text, 1) <> "" Then 
            rstForce.Open "select  " & strLp & " as myValue from DFieldForce where id='" & strZhengShu(i) & "'", Myconn, adOpenKeyset, adLockReadOnly 
            If Not rstForce.EOF Then 
    '          strAlterDegree(i) = rstForce.Fields!myValue & "" 
              strAlterDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue]) 
              If strAlterDegree(i) = "" Then GoTo continue 
            End If 
            rstForce.Close 
            rstForce.Open "select " & strLp & " as myValue from DFieldForce where id='" & Val(strZhengShu(i)) + 1 & "'", Myconn, adOpenKeyset, adLockReadOnly 
            If Not rstForce.EOF Then 
              strNextDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue]) 
              If strNextDegree(i) = "" Then GoTo continue 
            End If 
            rstForce.Close 
    continue:  
    Next i
      

  12.   

        For i = 0 To 9
           strAlterDegree(i) = "": strNextDegree(i) = ""
           If Right(txtRm(i).Text, 1) <> "0" And Right(txtRm(i).Text, 1) <> "" Then
            rstForce.Open "select  " & strLp & " as myValue from DFieldForce where id='" & strZhengShu(i) & "'", Myconn, adOpenKeyset, adLockReadOnly
            If Not rstForce.EOF Then
    '           strAlterDegree(i) = rstForce.Fields!myValue & ""
               strAlterDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue])
               If strAlterDegree(i) = "" Then GoTo continue
            End If
            rstForce.Close
            rstForce.Open "select " & strLp & " as myValue from DFieldForce where id='" & Val(strZhengShu(i)) + 1 & "'", Myconn, adOpenKeyset, adLockReadOnly
            If Not rstForce.EOF Then
               strNextDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue])
               If strNextDegree(i) = "" Then GoTo continue
            End If
            rstForce.Close
            sngForce(i) = Val(strAlterDegree(i)) - ((Val(strZhengShu(i)) - Val(txtRm(i).Text)) / (Val(strZhengShu(i)) - (Val(strZhengShu(i)) + 1)) * (Val(strAlterDegree(i)) - Val(strNextDegree(i))))
            sngForce(i) = XFormat(sngForce(i), "0.0")
          Else
             rstForce.Open "select " & strLp & " as myValue from DFieldForce where id='" & strZhengShu(i) & "'", Myconn, adOpenKeyset, adLockReadOnly
             If Not rstForce.EOF Then
                strAlterDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue])
                If strAlterDegree(i) = "" Then GoTo continue
             End If
             rstForce.Close
             sngForce(i) = Val(strAlterDegree(i))
          End If
             sngSumForce = sngSumForce + sngForce(i)
    continue:   Next i
      

  13.   

    其实可以不用看第一个判断
      for i=0 to 9
     rstForce.Open "select  " & strLp & " as myValue from DFieldForce where id='" & strZhengShu(i) & "'", Myconn, adOpenKeyset, adLockReadOnly 
            If Not rstForce.EOF Then 
    '          strAlterDegree(i) = rstForce.Fields!myValue & "" 
              strAlterDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue]) 
              If strAlterDegree(i) = "" Then GoTo continue 
            End If 
            rstForce.Close 
            rstForce.Open "select " & strLp & " as myValue from DFieldForce where id='" & Val(strZhengShu(i)) + 1 & "'", Myconn, adOpenKeyset, adLockReadOnly 
            If Not rstForce.EOF Then 
              strNextDegree(i) = IIf(IsNull(rstForce.Fields![myValue]), "", rstForce.Fields![myValue]) 
              If strNextDegree(i) = "" Then GoTo continue 
            End If 
    rstForce.Close 
    continue:  
    Next i
    关键就是这一段,第一个打开记录的时候