|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
因为ASP脚本语言非常简单,因此其代码也简单易懂,结合HTML代码,可快速地完成网站的应用程序。还无法完全实现一些企业级的功能:完全的集群、负载均横。编程|把持|数据|数据库十分有代价的代码,上面的代码是利用ADSI的工具数据库观点体例成的,只需你了解了我在后面文章说的器材,上面的代码只不外是ADSI牛刀小试罢了只需有了上面这个思绪,今后不管是凑合甚么数据库,就是不晓得数据库的布局也不必惧怕了。
<%
---defineDSNnamesinarray
database_list=Array("dsn_1","dsn_2","dsn_3")
---enabledeletingtable?--Carefull!!
strEnableDeleteTable=False
----enddeclaration
----donotchangecodebelowthisline---------------------------------------------
field_value=Array("Integer","Double","char(255)","Memo","Date","Currency","YesNo")
field_display=Array("Integer","Number","Text","Memo","Date/Time","Currency","Yes/No")
dsn_name=Request("DatabaseName")
IfNotdsn_name=""Then
Setcon=Server.CreateObject("ADODB.Connection")
con.Open"DSN="&dsn_name
EndIf
table_name=Request("TableName")
IfRequest("AddNewTable")""Then
IfRequest("NewTableName")""Then
SQL="CREATETABLE"&Request("NewTableName")&"(fldAutoCounter)"
con.Execute(SQL)
EndIf
EndIf
IfRequest("AddNewField")""Then
Ifrequest("NewFieldName")""Then
SQL="ALTERTABLE"&table_name&"ADD"&request("NewFieldName")&""&request("NewFieldType")&"NULL"
con.Execute(SQL)
EndIf
EndIf
IfRequest("DeleteTable")""Then
SQL="DROPTABLE"&Request("TableName")
Con.Execute(SQL)
EndIf
IfRequest("DeleteColumn")""Then
ForEachitemInRequest("DeleteCol")
SQL="ALTERTABLE"&Request("TableName")&"DROP"&item
con.Execute(SQL)
Next
EndIf
-----filename--------------------------------------------------------
file=Request.ServerVariables("SCRIPT_NAME")
file=strReverse(file)
pos=Instr(file,"/")
file=Left(file,pos-1)
file=strReverse(file)
%>
<%
response.write"<!DOCTYPEHTMLPUBLIC""-//W3C//DTDHTML3.2Final//EN"">"
response.write"<HTML><HEAD><TITLE>DatabaseControl</TITLE></HEAD>"
response.write"<BODYbgcolor=""#FFFFFF""><br><br><center>"
------------------------------------------------------------
response.write"<formaction="""&file&"""method=post>"
response.write"<b><fontface=verdanasize=3color=""#008080""><u>TotalDatabaseControl</u></font></b><br><br>"
response.write"<fontface=Verdana,Arialsize=2><b>DatabaseName:</b></font>"
response.write"<selectname=""databasename"">"
Fori=0touBound(database_list)
Ifdatabase_list(i)=Request("databasename")Then
response.write"<optionvalue="""&database_list(i)&"""selected>"&database_list(i)
Else
response.write"<optionvalue="""&database_list(i)&""">"&database_list(i)
EndIf
Next
response.write"</select>"
response.write"<inputtype=submitname=GoDatabasevalue=go>"
response.write"<hr></form>"
-------------------------------------------------------------
response.write"<formaction="""&file&"?DatabaseName="&Server.URLEncode(dsn_name)&"""method=post>"
Ifdsn_name""Then
Settable=con.OpenSchema(20)
response.write"<fontface=Verdana,Arialsize=2>TableNamesin"&dsn_name&":</font><SELECTNAME=TableName>"
WhileNottable.EOF
tblName=table("Table_Name")
IfLeft(tblName,4)"MSys"ANDLeft(tblName,3)"sys"ANDLeft(tblName,4)"RTbl"Then
IftblName=table_nameThen
response.write"<OPTIONVALUE="""&tblName&"""selected>"&tblName
Else
response.write"<OPTIONVALUE="""&tblName&""">"&tblName
EndIf
EndIf
table.MoveNext
Wend
response.write"</SELECT>"
response.write"<INPUTtype=submitname=tablevalue=go>"
IfstrEnableDeleteTable=TrueThen
response.write"<inputtype=submitname=DeleteTablevalue=delete>"
EndIf
response.write"</form>"
response.write"<formaction="""&file&"?DatabaseName="&Server.URLEncode(dsn_name)&"""method=post>"
response.write"<table><tr>"
response.write"<tdcolspan=2><fontface=Verdana,Arialsize=2color=""#ff0000"">AddNewTableinto"&dsn_name&"</font></td>"
response.write"</tr><tr>"
response.write"<th><fontface=Verdana,Arialsize=2>TableName:</font></th>"
response.write"<td><inputtype=textname=NewTableName></td>"
response.write"</tr><tr>"
response.write"<tdcolspan=2align=center><inputtype=submitname=AddNewTablevalue=""AddNewTable""></td></tr></table>"
response.write"</form><hr>"
EndIf
Iftable_name""ANDRequest("DeleteTable")=""Then
response.write"<formaction="""&file&"?DatabaseName="&Server.URLEncode(dsn_name)&"&TableName="&table_name&"""method=post>"
response.write"<tableborder=2align=centercellpadding=2cellspacing=2>"
response.write"<tr>"
response.write"<thcolspan=4align=left><fontface=Verdana,Arialsize=3color=teal>"&table_name&"</font></th>"
response.write"</tr><tr><th><fontface=Verdana,Arialsize=2>FieldName</font></th>"
response.write"<th><fontface=Verdana,Arialsize=2>FieldSize</font></th>"
response.write"<th><fontface=Verdana,Arialsize=2>FieldDataType</font></th>"
response.write"<th><fontface=Verdana,Arialsize=2>Delete</font></th></tr>"
SQL="SELECT*FROM"&table_name
Setrs=con.Execute(SQL)
ForeachfldNameinrs.Fields
response.write"<tr>"
response.write"<td><fontface=Verdana,Arialsize=2color=""#000000"">"&fldName.Name&"</font></td>"
response.write"<td><fontface=Verdana,Arialsize=2color=""#000000"">"&fldName.DefinedSize&"</font></td>"
response.write"<td><fontface=Verdana,Arialsize=2color=""#000000"">"&GetTypeName(fldName.Type)&"</font></td>"
response.write"<tdalign=center><inputtype=checkboxname=DeleteColvalue="""&fldName.Name&"""></td>"
response.write"</tr>"
Next
response.write"<tr><tdcolspan=4align=center><inputtype=submitname=DeleteColumnvalue=""DeleteSelectedColumn""></td></tr>"
response.write"</table>"
response.write"<table><tr>"
response.write"<tdcolspan=2><fontface=Verdana,Arialsize=2color=""#ff0000"">AddNewFieldinto"&table_name&"</font></td>"
response.write"</tr><tr>"
response.write"<th><fontface=Verdana,Arialsize=2>FieldName:</font></th>"
response.write"<td><inputtype=textname=""NewFieldName""></td>"
response.write"</tr><tr>"
response.write"<th><fontface=Verdana,Arialsize=2>FieldType:</font></th>"
response.write"<td><selectname=""NewFieldType"">"
Fori=0touBound(field_value)
response.write"<optionvalue="""&field_value(i)&""">"&field_display(i)
Next
response.write"</select></td></tr>"
response.write"<tr><tdcolspan=2align=center><inputtype=submitname=AddNewFieldvalue=""AddNewField""></td></tr></table>"
response.write"</form>"
EndIf
response.write"</center></BODY></HTML>"
FunctionGetTypeName(id)
SelectCaseid
Case"3"
GetTypeName="Number"
Case"200"
GetTypeName="Text"
Case"129"
GetTypeName="Text"
Case"201"
GetTypeName="Memo"
Case"6"
GetTypeName="Currency"
Case"11"
GetTypeName="Yes/No"
Case"5"
GetTypeName="Number"
Case"7","133","134","135"
GetTypeName="Date/Time"
CaseElse
GetTypeName=id
EndSelect
EndFunction
SubSelectDataType(it)
response.write"<SELECTNAME=EditColName>"
Fori=0toUBOUND(field_value)
Iffield_display(i)=itThen
response.write"<optionvalue="""&field_value(i)&"""selected>"&field_display(i)
Else
response.write"<optionvalue="""&field_value(i)&""">"&field_display(i)
EndIf
Next
response.write"</Select>"
EndSub
%>
想法是和程序员的想法不一样的.至于为什么.大家去想一想.跟心理学有关的 |
|