06. september 2001 - 11:16
Der er
1 løsning
check på primary key
Kan man fra ASP lave et check på om første felt i en database er sat til :
for access: autonummering
for sql:
indentity=yes, indentity seed=1,indentity increment=1
14. september 2001 - 18:45
#1
Prøv at se om ikke, det her kan bruges til noget:
<%
on error resume next
sTableName = \"tabelnavn\"
rs.Open \"[\" & sTableName & \"]\",,,adCmdTable
if rs.fields.count = 0 then
response.write \"No fields defined for table.\"
CloseRS
response.end
end if
if err <> 0 then
response.write err.number & \":\" & err.description & \"<br><br>\"
end if
for each fld in rs.fields
sFieldType = \"\"
sAttributes = \"\"
select case fld.Type
case adSmallInt : sFieldType = \"integer\"
case adInteger : sFieldType = \"long\"
case adBoolean : sFieldType = \"boolean\"
case adDate : sFieldType = \"date\"
case adCurrency : sFieldType = \"currency\"
case adVarWChar : sFieldType = \"text\"
case adLongVarWChar : sFieldType = \"memo\"
case adLongVarBinary : sFieldType = \"ole\"
case adGUID : sFieldType = \"guid\"
case adUnsignedTinyInt : sFieldType = \"byte\"
case else : sFieldType = fld.type
end select
if fld.properties(\"IsAutoIncrement\") = true then
sAttributes = sAttributes & \"(auto increment)\"
end if
\'Actually this won\'t work, any recommendations are welcome
if (fld.attributes and adFldKeyColumn) = adFldKeyColumn then
sAttributes = sAttributes & \" (primary key)\"
end if
if (fld.attributes and adFldUpdatable) = adFldUpdatable then
sAttributes = sAttributes & \" (updatable)\"
end if
if (fld.attributes and adFldIsNullable) = adFldIsNullable then
sAttributes = sAttributes & \" (nullable)\"
end if
if (fld.attributes and adFldFixed) = adFldFixed then
sAttributes = sAttributes & \" (fixed)\"
end if
\'if (fld.attributes and adFldMayBeNull) = adFldMayBeNull then
\' sAttributes = sAttributes & \" (may be null)\"
\'end if
if (fld.attributes and adFldLong) = adFldLong then
sAttributes = sAttributes & \" (long)\"
end if
if (fld.attributes and adFldRowID) = adFldRowID then
sAttributes = sAttributes & \" (row id)\"
end if
if (fld.attributes and adFldIsRowURL) = adFldIsRowURL then
sAttributes = sAttributes & \" (url)\"
end if
%>