我尝试使用ADO创建一个断开连接的记录集,包括备注字段(adLongVarWChar)。 出于某种原因,它会被转换回adVarWChar。 我做错了什么?
Private Sub Form_Load()
Dim rs As New Recordset
rs.Fields.Append "test", adLongVarWChar, 512, adFldIsNullable Or adFldLong Or adFldMayBeNull Or adFldMayDefer Or adFldUnknownUpdatable
Debug.Print rs.Fields(0).Type & " <- This should be 203 (adLongVarWChar) but it returns 202 (adVarWChar)"
Unload Me
End Sub
答案 0 :(得分:1)
事实证明,出于某种原因,您需要先添加一条记录,然后DataType正确返回:
Private Sub Form_Load()
Dim rs As New Recordset
rs.Fields.Append "test", adLongVarWChar, &H7FFFFFFF, adFldIsNullable Or adFldLong Or adFldMayBeNull Or adFldMayDefer Or adFldUnknownUpdatable
Debug.Print rs.Fields(0).Type & " <- This should be 203 (adLongVarWChar) but it returns 202 (adVarWChar)"
rs.Open
rs.AddNew
rs.Update
Debug.Print rs.Fields(0).Type & " <- This is now 203 (adLongVarWChar)"
Unload Me
End Sub