判断SQL数据库的我已解决,写了一个通用函数,调用即可。
'
'判断某列是否是标识列:是标识列,则返回:True、否则返回:False
Public Function IsIdentityField(ByVal strFieldName As String, ByVal strTableName As String) As Boolean
On Error GoTo Err_Handler
Dim blnResult As Boolean
Dim varValue As Variant
Dim rst As Object
Dim strSQL As String
blnResult = False
varValue = 0
strSQL = "SELECT COLUMNPROPERTY(OBJECT_ID('" & strTableName & "'),'" & strFieldName & "','IsIdentity')"
If GetRecordset(rst, strSQL) Then
If rst.RecordCount > 0 Then
varValue = Nz(rst.Fields(0).Value, "NotFould")
End If
rst.Close
End If
If varValue = "NotFould" Then
MsgBox "指定的数据表名[" & strTableName & "] 或 字段名[" & strFieldName & "]不存在!", vbExclamation, "提示"
Else
blnResult = varValue <> 0
End If
Exit_Handler:
IsIdentityField = blnResult
Set rst = Nothing
Exit Function
Err_Handler:
blnResult = False
MsgBox Err.Description, vbExclamation, "判断列是否是标识列出错"
Resume Exit_Handler
End Function 作者: Henry D. Sy 时间: 2011-12-7 22:02