Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Read Column's Default Value into Variable
 New Topic  Reply to Topic
 Printer Friendly
Author  Topic Next Topic  

Carefree
Advanced Member

Philippines
4206 Posts

Posted - 09 November 2021 :  21:41:59  Show Profile  Reply with Quote
I can extract and display a column's default property, but haven't figured out how to assign it to a variable. For example:


	For Each Table in adoxConn.Tables
		If LCase(Table.Name) = LCase(strTable) Then
			IsThere = "True"
			Response.Write	"<form action=""admin_db_defs.asp"" method=""post"">" & vbNewLine & _
				"	<input type=""hidden"" name=""cedit"" value=""" & LCase(Table.Name) & """ />" & vbNewLine & _
				"	<input type=""hidden"" name=""tname"" value=""" & Table.Name & """ />" & vbNewLine & _
				"	<table align=""center"" class=""tbl"" bgcolor=""" & strPopupTableColor & """ cellspacing=""0"" celllpadding=""0"" />" & vbNewLine & _
				"		<tr>" & vbNewLine & _
				"			<td align=""center""><h1>" & strTable & "</h1>" & vbNewLine & _
				"			 	<table width=""100%"" border=""1"" style=""border-collapse:collapse;"" cellspacing=""1"" cellpadding=""4"">" & vbNewLine & _
				"		   		 	<tr>" & vbNewLine & _
				"					      	<td align=""center"" bgcolor=""" & strCategoryCellColor & """ colspan=""6"">" & vbNewLine & _
				"							<font color=""" & strCategoryFontColor & """ size=""" & strHeaderFontSize+1 & """><b>Field Definitions</b></font>" & vbNewLine & _
				"						</td>" & vbNewLine & _
				"					</tr>" & vbNewLine &  _
				"			    		<tr>" & vbNewLine & _
				"		    	 			 <td align=""center"" bgcolor=""" & strHeadCellColor & """>" & vbNewLine & _
				"							<font color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize & """><b>Name</b></font>" & vbNewLine & _
				"						</td>" & vbNewLine & _
				"			      			<td align=""center"" bgcolor=""" & strHeadCellColor & """>" & vbNewLine & _
				"							<font color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize & """><b>Type</b></font>" & vbNewLine & _
				"						</td>" & vbNewLine & _
				"		    	 			 <td align=""center"" bgcolor=""" & strHeadCellColor & """>" & vbNewLine & _
				"							<font color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize & """><b>Size</b></font>" & vbNewLine & _
				"						</td>" & vbNewLine & _
				"		    	  			<td align=""center"" bgcolor=""" & strHeadCellColor & """>" & vbNewLine & _
				"							<font color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize & """><b>Allow Null</b></font>" & vbNewLine & _
				"						</td>" & vbNewLine & _
				"		    	  			<td align=""center"" bgcolor=""" & strHeadCellColor & """>" & vbNewLine & _
				"							<font color=""" & strHeadFontColor & """ size=""" & strHeaderFontSize & """><b>Default Value</b></font>" & vbNewLine & _
				"						</td>" & vbNewLine & _
				"			     			 <td align=""center"" bgcolor=""" & strHeadCellColor & """> " & vbNewLine & _
				"						</td>" & vbNewLine &  _
				"					</tr>" & vbNewLine
			intI = 0
			For Each Column in Table.Columns
				If intI = 0 Then CColor = strForumCellColor Else CColor = strAltForumCellColor
				Response.Write	"					<tr bgColor = """ & CColor & """>" & vbNewLine & _
					"						<td><font color=""" & strDefaultFontColor & """ size=""" & strDefaultFontSize & """ face=""" & strDefaultFontFace & """>"&Column.Name&"</font></td>" & vbNewLine & _
					"						<td><font color=""" & strDefaultFontColor & """ size=""" & strDefaultFontSize & """ face=""" & strDefaultFontFace & """>"
				intCT = Column.Type
				strType = "OLEObject"
				If intCT = 2 Then strType = "Small Int"
				If intCT = 3 Then strType = "Long Int"
				If intCT = 4 Then strType = "Single"
				If intCT = 5 Then strType = "Double"
				If intCT = 6 Then strType = "Currency"
				If intCT = 7 Then strType = "Date"
				If intCT = 17 Then strType = "Byte"
				If intCT = 72 Then strType = "Replica"
				If intCT = 130 Then strType = "Char"
				If intCT = 131 Then strType = "Numeric"
				If intCT = 202 Then strType = "Varchar"
				If intCT = 203 Then strType = "Memo"
				If intCT = 204 Then strType = "Attachment"
				If Column.DefinedSize = 0 Then
					intCS = 1
				Else
					intCS = Column.DefinedSize
				End If
				If strType = "Memo" Then intCS = 65535
				If Column.Properties("Nullable") Then
					strN="<b>Y</b> "
				Else
					strN = "<font color=""" & strHiLiteFontColor & """><b><s>N</s></b> </font>"
				End If
				If Column.Properties("AutoIncrement") Then
					strType = "AutoIncrement"
					strN = "<font color=""" & strHiLiteFontColor & """><b><s>N</s></b> </font>"
				End If
				strCPD = Column.Properties("Default")
				Response.Write	strType & "						</font></td>" & vbNewLine & _
					"						<td align=right><font color=""" & strDefaultFontColor & """ size=""" & strDefaultFontSize & """ face=""" & strDefaultFontFace & """>"&intCS&"</font></td>" & vbNewLine & _
					"						<td align=center>" & strN & "</td>" & vbNewLine & _
					"						<td align=center>" & Column.Properties("Default") & "</td>" & vbNewLine & _

That last line will display the default value, but strCPD will never be assigned a value.

Edited by - Carefree on 16 November 2021 14:18:00
   Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.17 seconds. Powered By: Snitz Forums 2000 Version 3.4.07