-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathte_tableedit.asp
238 lines (213 loc) · 8.05 KB
/
te_tableedit.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<%
'==============================================================
' TableEditoR 0.81 Beta
' http://www.2enetworx.com/dev/projects/tableeditor.asp
'--------------------------------------------------------------
' File: te_tableedit.asp
' Description: Displays the table structure for modification
' Initiated By Hakan Eskici on Nov 15, 2000
'--------------------------------------------------------------
' Copyright (c) 2002, 2eNetWorX/dev.
'
' TableEditoR is distributed with General Public License.
' Any derivatives of this software must remain OpenSource and
' must be distributed at no charge.
' (See license.txt for additional information)
'
' See Credits.txt for the list of contributors.
'
' Change Log:
'--------------------------------------------------------------
'==============================================================
%>
<!--#include file="te_config.asp"-->
<!--#include file="te_header.asp"-->
<table border=0 cellspacing=1 cellpadding=2 bgcolor = "#ffe4b5" width="100%">
<tr>
<td class="smallertext">
<a href="index.asp">Home</a> » <a href="te_admin.asp">Connections</a> » <a href="te_listtables.asp?cid=<%=request("cid")%>"><%=arrDesc(request("cid"))%></a> » Edit Table [<%=request("tablename")%>]
</td>
<td class="smallerheader" width=130 align=right>
<%
if bProtected then
response.write session("teFullName")
response.write " (<a href=""te_logout.asp"">logout</a>)"
end if
%>
</td>
</tr>
</table>
<br>
<%
lConnID = request("cid")
sTableName = request("tablename")
OpenRS arrConn(lConnID)
if arrType(lConnID) = tedbDsn then
response.write "Table Structure modification might not work as expected with Dsn connections.<br><br>"
end if
%>
<table border=0 cellspacing=1 cellpadding=2 bgcolor="#ffdead" width="100%"<% if bTableHighlight then response.write " style=""behavior:url(tablehl.htc);"" slcolor=#ffffcc hlcolor=#bec5de"%>>
<thead>
<tr>
<td width=10></td>
<td class="smallerheader" colspan=4>Field Definitions
<%
if bFldAdd and bTableEdit then
%>
(<a href="te_fieldedit.asp?cid=<%=lConnID%>&tablename=<%=server.urlencode(sTableName)%>">Add a new field</a>)
<% end if %>
</td>
</tr>
<tr>
<td bgcolor="#fffaf0" width=10></td>
<td bgcolor="#fffaf0" class="smallerheader">Field Name</td>
<td bgcolor="#fffaf0" class="smallerheader">Field Type</td>
<td bgcolor="#fffaf0" class="smallerheader">Size</td>
<td bgcolor="#fffaf0" class="smallerheader">Attributes</td>
<td bgcolor="#fffaf0" class="smallerheader" align=right width=100>Action</td>
<td bgcolor="#fffaf0" width=10></td>
</tr>
</thead>
<tbody>
<%
on error resume next
rs.Open "[" & sTableName & "]",,,adCmdTable
if rs.fields.count = 0 then
response.write "No fields defined for table."
CloseRS
%><!--#include file="te_footer.asp"--><%
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"
' begin added for SQL2000 2001-04-20 15:46 <[email protected]>
case adBigInt : sFieldType = "bigint"
case adBinary : sFieldType = "binary"
case adNumeric : sFieldType = "decimal"
case adVarChar : sFieldType = "varchar"
case adDouble : sFieldType = "double"
case adWChar : sFieldType = "nchar"
case adVariant : sFieldType = "variant"
case adVarBinary : sFieldType = "varbinary"
case adChar : sFieldType = "char"
case adDBTimeStamp : sFieldType = "datetime"
case adLongVarChar : sFieldType = "text (long)"
case adSingle : sFieldType = "single"
' end added for SQL2000 2001-04-20 15:46 <[email protected]>
case else : sFieldType = fld.type
end select
isAutoIncrement4DSN = ""
if fld.properties("IsAutoIncrement") = true then
sAttributes = sAttributes & "(auto increment)"
if arrType(lConnID) <> tedbAccess then isAutoIncrement4DSN = "&autoinc=1"
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
' sAttributes = sAttributes & " (" & fld.attributes & ")"
%>
<tr bgcolor="#fffaf0">
<td width=10></td>
<td class="smallertext"><%=fld.name%></td>
<td class="smallertext"><%=sFieldType%></td>
<td class="smallertext"><%=fld.definedsize%></td>
<td class="smallertext"><%=sAttributes%></td>
<td class="smallertext" align=right>
<% if bFldEdit and bTableEdit then %>
<a href="te_fieldedit.asp?cid=<%=lConnID%>&tablename=<%=server.urlencode(sTableName)%>&fldname=<%=server.urlencode(fld.name)%><% =isAutoIncrement4DSN %>">edit</a>
<%
end if
if bFldDel and bTableEdit then
%>
<a href="te_fieldremove.asp?cid=<%=lConnID%>&tablename=<%=server.urlencode(sTableName)%>&fldname=<%=server.urlencode(fld.name)%>">remove</a>
<% end if %>
</td>
<td width=10></td>
</tr>
<%
next
response.write "</tbody></table><br>"
rs.close
'List Indexes of this table
set rs = conn.openSchema(adSchemaIndexes)
%>
<table border=0 cellspacing=1 cellpadding=2 bgcolor="#ffdead" width="100%"<% if bTableHighlight then response.write " style=""behavior:url(tablehl.htc);"" slcolor=#ffffcc hlcolor=#bec5de "%>>
<thead>
<tr>
<td width=10></td>
<td class="smallerheader" colspan=4>Indexes</td>
</tr>
<tr>
<td bgcolor="#fffaf0" width=10></td>
<td bgcolor="#fffaf0" class="smallerheader">Index Name</td>
<td bgcolor="#fffaf0" class="smallerheader">Indexed Column</td>
<td bgcolor="#fffaf0" class="smallerheader">Primary Key</td>
<td bgcolor="#fffaf0" class="smallerheader">Unique</td>
<td bgcolor="#fffaf0" class="smallerheader" align=right width=100>Action</td>
<td bgcolor="#fffaf0" width=10></td>
</tr>
</thead>
<tbody>
<%
if arrType(lConnID) = tedbDsn then
response.write "<tr bgcolor=""#fffaf0""><td></td><td class=""smallertext"" colspan=""5"">Unable to get indexes for Dsn connections.</td><td></td></tr>"
end if
do while not rs.eof
if rs("table_name") = sTableName then
response.write "<tr bgcolor=""#fffaf0""><td width=10></td>"
response.write "<td class=""smallertext"">" & rs("Index_name") & "</td>"
response.write "<td class=""smallertext"">" & rs("column_name") & "</td>"
response.write "<td class=""smallertext"">" & rs("prImary_key") & "</td>"
response.write "<td class=""smallertext"">" & rs("unIque") & "</td>"
response.write "<td class=""smallertext"" align=right>"
if bFldDel then
%>
<a href="te_indexremove.asp?cid=<%=lConnID%>&tablename=<%=server.urlencode(sTableName)%>&idxname=<%=rs("Index_name")%>">remove</a>
<%
end if
response.write "</td>"
response.write "<td width=10></td></tr>"
end if
rs.movenext
loop
response.write "</tbody></table>" & vbCrLf
CloseRS
%>
<!--#include file="te_footer.asp"-->