问题如下    dim a as new adodb.connection
    dim b as new adodb.recordset
    con.Open "DSN=qianggege;uid=wq;pwd=wq;"
    rs.CursorLocation = adUseClient
    rs.Open "qianggege", con, adOpenKeyset, adLockOptimistic, adCmdTable
    Text1.Text = rs("code")
    Text2.Text = rs("name")
当我记录name为空的时候就会出现错误,我想用if then else end if 的语句排除这个毛病,但If rs("name") = Null Then
       Text32.Text = " "
        Else
       Text2.Text = rs("name")
         End If
是不对的那么那个当记录的name为空的时候我应该用什么代替

解决方案 »

  1.   

    试试
    If isnull(rs("name")) Then
           Text32.Text = " "
    Else
           Text2.Text = rs("name")
    End If
      

  2.   

    If not isnull(rs("name")) Then
       Text2.Text = rs("name")
    else
       Text2.Text = ""
    endif
      

  3.   

    If  isnull(rs("name")) Then
           Text32.Text = " "
            Else
           Text2.Text = rs("name")
             End If
      

  4.   

    这样试试:
    Text2.Text = rs("name") & ""
      

  5.   

    看這樣行不:
        Text2.Text =iif(isnull(rs("name")),"",rs("name"))
      

  6.   

    Text1.Text = rs("code")
        Text2.Text = rs("name")
    程序应该会在上面的一行中出错,我认为应当这样写:
        Text2.Text=IIf(IsNull(rs("name")),"",rs("name"))
      

  7.   

    Text2.Text = rs("name") & "" '强制转换成字符串,Null时为空串
      

  8.   

    Text1.Text = "" & rs("code")
    Text2.Text = "" & rs("name")
      

  9.   

    Text2.Text = rs("name") & ""