-
Notifications
You must be signed in to change notification settings - Fork 0
/
te_procedit.asp
168 lines (145 loc) · 4.42 KB
/
te_procedit.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
<%
'==============================================================
' TableEditoR 0.81 Beta
' http://www.2enetworx.com/dev/projects/tableeditor.asp
'--------------------------------------------------------------
' File: te_queryedit.asp
' Description: Edits or creates a query
' Initiated By Hakan Eskici on Nov 22, 2000
'--------------------------------------------------------------
' Copyright (c) 2001, 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 23, 2000 by Hakan Eskici
' Changed the query name assignment which caused a bug in
' creating and editing queries.
'==============================================================
%>
<!--#include file="te_config.asp"-->
<%
sub ShowForm
%>
<!--#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> » <%=sAction%>
</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>
<p class="smallerheader">
<%=sAction%><br><br><%=sErr%>
</p>
<form action="te_procedit.asp?cid=<%=lConnID & sAdd%>&queryname=<%=sQueryName%>" method="post">
<table border=0>
<tr>
<td class="smallerheader">Procedure Name</td>
<td><input type="text" name="txtQueryName" class="tbflat" value="<%=sQueryName%>"></td>
</tr>
<tr>
<td class="smallerheader">SQL</td>
<td>
<textarea cols=60 rows=8 name="txtSQL" class="tbflat"><%=sSQL%></textarea>
</td>
</tr>
<tr>
<td class="smallerheader" colspan=2>Syntax:
Write "PARAMETERS 1st_par_name 1st_par_type, 2nd_par_name 2nd_par_type, ... ;"<br> and then the Sql query text followed by ";"<br>
ex. PARAMETERS pippo Long; SELECT * FROM users WHERE id_user > pippo;<br>
<font color="red"><u><b>ATTENTION: The Sql Query created/modified in this way<br> will not be readable(nor visible, nor editable) by Ms Access 2000<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc2k/html/adocreateq.asp">(Read More)</a>.</b></u></font>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="cmdSave" value=" Save " class="cmdflat"></td>
</tr>
</table>
</form>
<!--#include file="te_footer.asp"-->
<%
end sub
lConnID = request("cid")
sQueryName = request("txtQueryName")
sSQL = request("txtSQL")
sQueryName = request("queryname")
sNewQueryName = request("txtQueryName")
'on error resume next
if request("add") <> "" then
bAdd = True
sAdd = "&add=1"
sAction = "Create new Stored Procedure"
else
bAdd = False
sAction = "Edit Stored Procedure"
if request("cmdSave") <> "" then
sSQL = request("txtSQL")
else
OpenRS arrConn(lConnID)
set cmd = server.createobject("adodb.command")
set cat = server.createobject("adox.catalog")
set cat.ActiveConnection = conn
set cmd.ActiveConnection = conn
set views = cat.procedures
set cmd = views(sQueryName).Command
sSQL = cmd.CommandText
conn.close
set conn=nothing
set rs=nothing
set cmd=nothing
set cat=nothing
end if
end if
if request("cmdSave") <> "" then
OpenRS arrConn(lConnID)
set cmd = server.createobject("adodb.command")
set cat = server.createobject("adox.catalog")
set cat.ActiveConnection = conn
set cmd.ActiveConnection = conn
cmd.CommandText = sSQL
set views = cat.procedures
if bAdd then
if sQueryName = "" then
sQueryName = sNewQueryName
end if
views.append sQueryName, cmd
else
views(sQueryName).Command = cmd
'Cannot rename
'views(sQueryName).Name = sNewQueryName
end if
if err <> 0 then
sErr = "Error : <br>" & err.description
bErr = True'
conn.close
set conn=nothing
set rs=nothing
set cmd=nothing
set cat=nothing
ShowForm
else
conn.close
set conn=nothing
set rs=nothing
response.redirect "te_listtables.asp?cid=" & lConnID
end if
else
ShowForm
end if
%>