-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathte_listtables.asp
325 lines (302 loc) · 10.3 KB
/
te_listtables.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<%
'==============================================================
' TableEditoR 0.81 Beta
' http://www.2enetworx.com/dev/projects/tableeditor.asp
'--------------------------------------------------------------
' File: te_listtables.asp
' Description: Lists the tables for a given connection
' Initiated By Hakan Eskici on Nov 01, 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:
'--------------------------------------------------------------
' # Nov 14, 2000 by Hakan Eskici
' Depending on the permissions, users will either see "info"
' or "edit" for the action with a link to te_tableedit.asp
' # Nov 17, 2000 by Hakan Eskici
' Added drop table links for tables and queries
' # Mar 27, 2001 by Hakan Eskici
' Added showing stored procedures
' # Mar 29, 2001 by Hakan Eskici
' Fixed the cid=0 security bug
' # May 28, 2001 by Alain Jacquot
' Fixed the "Object or provider is not capable of performing requested operation" bug
' # June 03, 2001 by Rakesh Jain
' Rearranged the code so that system tables and data tables do not show under Queries
'==============================================================
%>
<!--#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> » <%
if bComboTables then
allTablesCombo()
else
response.write arrDesc(request("cid"))
end if %></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>
<p class="smallerheader">
Select a table
<%
if bSQLExec then
response.write " or <a href=""te_query.asp?cid=" & request("cid") & """>Run a Query</a>"
end if
%>
</p>
<%
'Which connection to use?
lConnID = request("cid")
if (lConnID = 0) and bAdmin = False then
response.write "Not authorised to view this connection."
%><!--#include file="te_footer.asp"--><%
response.end
end if
conn.Open arrConn(lConnID)
set rs = conn.OpenSchema(adSchemaTables)
%>
<table border=0 cellspacing=1 cellpadding=2 bgcolor = "#ffe4b5" width="100%"<% if bTableHighlight then response.write " style=""behavior:url(tablehl.htc);"" slcolor='#ffffcc' hlcolor='#bec5de'"%>>
<thead>
<tr>
<td class="smallerheader" bgcolor="#ffe4b5" width=10>»</td>
<td bgcolor="#ffe4b5" class="smallerheader" colspan=3>
Tables
<%
if bTableAdd then
response.write " (<a href=""te_tablecreate.asp?cid=" & request("cid") & """>Create a new table</a>)"
end if
if bAllowImport then
response.write " (<a href=""te_xml_import.asp?cid=" & request("cid") & """>Import Data</a>)"
end if
%>
</td>
</tr>
<tr>
<td class="smallerheader" bgcolor="#fffaf0" width=10></td>
<td class="smallerheader" bgcolor="#fffaf0">Table Name</td>
<td class="smallerheader" bgcolor="#fffaf0">Description</td>
<td class="smallerheader" bgcolor="#fffaf0" align=right width=150>Action</td>
<td bgcolor="#fffaf0" width=10></td>
</tr>
</thead>
<tbody>
<%
'Addition: Search Link
'By Kevin Yochum on Nov 07, 2000
if bTableEdit then sAction = "edit" else sAction = "info"
do while not rs.eof
if rs("table_type") = "TABLE" then
%>
<tr bgcolor="#fffaf0">
<td></td>
<td><a href="<% =TableViewerCompat %>?cid=<%=lConnID%>&tablename=<%=rs("table_name")%>"><%=rs("table_name")%></a></td>
<td class="smallertext"><%=rs("descrIptIon")%></td>
<td align=right>
<a href="te_searchtable.asp?cid=<%=lConnID%>&tablename=<%=rs("table_name")%>">search</a>
<a href="te_tableedit.asp?cid=<%=lConnID%>&tablename=<%=rs("table_name")%>&type=table"><%=sAction%></a>
<% if bTableDel then %>
<a href="te_tableremove.asp?cid=<%=lConnID%>&tablename=<%=rs("table_name")%>">remove</a>
<% end if %>
</td>
<td></td>
</tr>
<%
end if
rs.movenext
loop
rs.close
%>
</tbody>
</table>
<%
if bQueryExec then
%>
<br>
<table border=0 cellspacing=1 cellpadding=2 bgcolor="#ffe4b5" width="100%"<% if bTableHighlight then response.write " style=""behavior:url(tablehl.htc);"" slcolor='#ffffcc' hlcolor='#bec5de'"%>>
<thead>
<tr>
<td class="smallerheader" bgcolor="#ffe4b5" width=10>»</td>
<td bgcolor="#ffe4b5" class="smallerheader" colspan=3>
Queries
<%
if bTableAdd then
response.write " (<a href=""te_queryedit.asp?cid=" & request("cid") & "&add=1"">Create a new query</a>)"
end if
%>
</td>
</tr>
<tr>
<td class="smallerheader" bgcolor="#fffaf0" width=10></td>
<td class="smallerheader" bgcolor="#fffaf0">Query Name</td>
<td class="smallerheader" bgcolor="#fffaf0">Description</td>
<td class="smallerheader" bgcolor="#fffaf0" width=150 align=right>Action</td>
<td bgcolor="#fffaf0" width=10></td>
</tr>
</thead>
<tbody>
<%
' # May 28, 2001 by Alain Jacquot
' Fixed the "Object or provider is not capable of performing requested operation" bug
' # June 03, 2001 by Rakesh Jain
' Rearranged the code so that system tables and data tables do not show under Queries
select case arrType(lConnID)
Case tedbAccess
set rs = conn.OpenSchema(adSchemaViews)
Case tedbSQLServer
set rs = conn.OpenSchema(adSchemaTables)
Case tedbDSN
set rs = conn.OpenSchema(adSchemaTables)
Case tedbConnStr
set rs = conn.OpenSchema(adSchemaViews)
Case else
if (lConnID = 0) and bAdmin = True then
set rs = conn.OpenSchema(adSchemaTables)
else
response.write "Not authorised to view this connection."
%><!--#include file="te_footer.asp"--><%
response.end
end if
end select
do while not rs.eof
if arrType(lConnID) = tedbAccess then
bProceed = True
else
if rs("table_type") = "VIEW" then
bProceed = True
end if
end if
if bProceed then
%>
<tr bgcolor="#fffaf0">
<td></td>
<td><a href="<% =TableViewerCompat %>?cid=<%=lConnID%>&tablename=<%=rs("table_name")%>"><%=rs("table_name")%></a></td>
<td class="smallertext"><%=rs("descrIptIon")%></td>
<td align=right>
<% if arrType(lConnID) = tedbAccess then %>
<a href="te_queryinfo.asp?cid=<%=lConnID%>&tablename=<%=rs("table_name")%>&type=query">info</a>
<% end if %>
<% if bTableEdit and arrType(lConnID) = tedbAccess then %>
<a href="te_queryedit.asp?cid=<%=lConnID%>&queryname=<%=rs("table_name")%>">edit</a>
<% end if %>
<% if bTableDel then %>
<a href="te_tableremove.asp?cid=<%=lConnID%>&tablename=<%=rs("table_name")%>">remove</a>
<% end if %>
</td>
<td></td>
</tr>
<%
end if
rs.movenext
loop
rs.close
response.write "</tbody></table>"
end if
set rs = conn.OpenSchema(adSchemaProcedures)
%>
<br>
<table border=0 cellspacing=1 cellpadding=2 bgcolor = "#ffe4b5" width="100%"<% if bTableHighlight then response.write " style=""behavior:url(tablehl.htc);"" slcolor='#ffffcc' hlcolor='#bec5de'"%>>
<thead>
<tr>
<td class="smallerheader" bgcolor="#ffe4b5" width=10>»</td>
<td bgcolor="#ffe4b5" class="smallerheader" colspan=4>
Procedures
<%
if bTableAdd then
response.write " (<a href=""te_procedit.asp?add=1&cid=" & lConnID & """>Create a new stored procedure</a>)"
end if
%>
</td>
</tr>
<tr>
<td class="smallerheader" bgcolor="#fffaf0" width=10></td>
<td class="smallerheader" bgcolor="#fffaf0">Name</td>
<td class="smallerheader" bgcolor="#fffaf0">Parameters</td>
<td class="smallerheader" bgcolor="#fffaf0">Description</td>
<td class="smallerheader" bgcolor="#fffaf0" width=150 align=right>Action</td>
<td bgcolor="#fffaf0" width=10></td>
</tr>
</thead>
<tbody>
<%
set cat = server.createobject("adox.catalog")
cat.ActiveConnection = conn
do while not rs.eof
sProcName = rs("procedure_name")
sProcDef = rs("descrIptIon")
iProcType = rs("procedure_type")
select case arrType(lConnID)
case tedbSQLServer
aProcName = split(sProcName, ";")
iProcType = 0
if isArray(aProcName) then
sProcName = aProcName(0)
iParamCount = aProcName(1)
end if
case tedbAccess
iParamCount = cat.Procedures(sProcName).command.parameters.count
case else
iParamCount = 0
iProcType = 0
end select
'if (iProcType = 3) and arrType(lConnID)<>tedbSQLServer then
' sProcURL = "<a href=""te_execproc.asp?cid=" & lConnID & "&procname=" & server.htmlencode(sProcName) & """>" & sProcName & "</a>"
'else
' sProcURL = sProcName & "(" & sProcType & ")"
'end if
select case iProcType
case 2 'Non-parameterized query
if iParamCount > 0 then
sProcURL = "<a href=""te_execproc.asp?cid=" & lConnID & "&procname=" & server.htmlencode(sProcName) & """>" & sProcName & "</a>"
else
sProcURL = "<a href=""" & TableViewerCompat & "?cid=" & lConnID & "&tablename=" & server.htmlencode(sProcName) & """>" & sProcName & "</a>"
end if
case 3 'Query with parameters
sProcURL = "<a href=""te_execproc.asp?cid=" & lConnID & "&procname=" & server.htmlencode(sProcName) & """>" & sProcName & "</a>"
case else
sProcURL = "<a href=""te_procmanager.asp?cid=" & lConnID & "&action=alter&procname=" & server.htmlencode(sProcName) & """>" & sProcName & "</a>"
'sProcURL = sProcName
end select
%>
<tr bgcolor="#fffaf0">
<td></td>
<td class="smallertext"><%=sProcURL%></td>
<td class="smallertext"><%=iParamCount%></td>
<td class="smallertext"><%=sProcDef%></td>
<td align=right>
<% if arrType(lConnID) = tedbAccess then %>
<a href="te_queryinfo.asp?cid=<%=lConnID%>&tablename=<%=server.htmlencode(sProcName)%>&type=proc">info</a>
<% end if %>
<% if bTableEdit and arrType(lConnID) = tedbAccess then %>
<a href="te_procedit.asp?cid=<%=lConnID%>&queryname=<%=server.htmlencode(sProcName)%>">edit</a>
<% end if %>
<% if bTableDel then %>
<a href="te_tableremove.asp?cid=<%=lConnID%>&tablename=<%=server.htmlencode(sProcName)%>">remove</a>
<% end if %>
</td>
<td></td>
</tr>
<%
rs.movenext
loop
%>
</tbody>
</table>
<!--#include file="te_footer.asp"-->