【发布时间】:2013-12-21 19:01:02
【问题描述】:
我已经尝试过这段代码(ASP CLASSIC):
Public Function IsNullable(MyField)
Dim RS, SQL, Tmp
SQL = "SELECT " & MyField & " FROM mytable WHERE 1;"
Set RS = Server.CreateObject("ADODB.Recordset")
RS.Open SQL, conn 'I have connection opened elsewhere, using Driver={MySQL ODBC 5.2w Driver}
'Now check for Attributes
Tmp = RS.Fields(MyField).Attributes
IsNullable = 0 <> (Tmp And adFldIsNullable) '0x20
RS.Close
Set RS = Nothing
End Function
函数工作正常,但有时结果是错误的。例如,它为 ID 字段返回 True,该字段绝对不能为空,因为它是主索引自动增量。我怎样才能使它可靠?谢谢
添加:似乎当列设置为 AutoIncrement Not Null 时,函数工作错误...
【问题讨论】:
标签: mysql vbscript asp-classic ado