各位大侠,能不能得到SQLSERVER的字段描述值?有的话请给出简单的代码。谢谢

解决方案 »

  1.   

    Option ExplicitDim db As Database'以下 Function 需要二个参数,sTable 是 Table 名称,sField 是字段名称
    Function Getdescription(sTable As String, sField As String) As String
        Dim Sna As Recordset
        Dim i As Integer
        Dim existDescr As Boolean
        
        Set Sna = db.OpenRecordset(sTable, dbOpenTable)
        existDescr = False
        For i = 0 To Sna(sField).Properties.Count - 1
            If Sna(sField).Properties(i).Name = "Description" Then
                existDescr = True: Exit For
            End If
        Next    If existDescr Then
            Getdescription = Sna(sField).Properties("Description")
        Else
            Getdescription = ""
        End If
    End FunctionPrivate Sub Command1_Click()
        Dim x As String
        MsgBox Getdescription("AABLE_L", "AABLE_LNO")
    End SubPrivate Sub Form_Load()
        Set db = opendatabase("c:\hris\ability.mdb")  '数据库
    End Sub
    这是抓ACCESS的办法。
      

  2.   

    SELECT a.name AS 表名, b.name AS 字段, c.name AS 字段类型
    FROM sysobjects a INNER JOIN
          syscolumns b ON a.id = b.id INNER JOIN
          systypes c ON b.xtype = c.xtype
    WHERE (a.name = 't_mobile')
    把t_mobile替换成你想看的表名即可