ASP操作Access資料庫的程式。(轉)

來源:互聯網
上載者:User
access|程式|資料|資料庫 <%
'--- define DSN names in array
'--- enter one or more DSN name in the database_list array
database_list=Array("Test","test1")
'--- enable deleting table? -- Carefull!!
strEnableDeleteTable = False
'---- end declaration

'---- do not change code below this line ---------------------------------------------
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")
If Not dsn_name = "" Then
   Set con = Server.CreateObject("ADODB.Connection")
   Con.Provider = "sqloledb"
   if dsn_name = "Test" then
        ConStr = "Data Source =127.0.0.1;Initial Catalog=test;User ID=test;Password=1111"
   else      
        ConStr = "Data Source =127.0.0.1;Initial Catalog=test1;User ID=test1;Password=1111"
   end if
   con.Open constr
End If
table_name = Request("TableName")

If Request("AddNewTable")<>"" Then
    If Request("NewTableName") <> "" Then
        SQL = "CREATE TABLE " & Request("NewTableName") & " (fldAuto Counter)"
        con.Execute(SQL)
    End If
End If
If Request("AddNewField")<>"" Then
    If request("NewFieldName") <> "" Then
        SQL = "ALTER TABLE " & table_name & " ADD " & request("NewFieldName") & " " & request("NewFieldType") & " NULL"
        con.Execute(SQL)
    End If
End If
If Request("DeleteTable")<>"" Then
    SQL = "DROP TABLE " & Request("TableName")
    Con.Execute(SQL)
End If
If Request("DeleteColumn")<>"" Then
    For Each item In Request("DeleteCol")
        SQL = "ALTER TABLE " & Request("TableName") & " DROP " & item
        con.Execute(SQL)
    Next
End If
'----- file name--------------------------------------------------------
file = Request.ServerVariables("SCRIPT_NAME")
file = strReverse(file)
pos = Instr(file,"/")
file = Left(file, pos-1)
file = strReverse(file)
%>

<%
response.write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 3.2 Final//EN"">"
response.write "<HTML><HEAD><TITLE>Database Control</TITLE></HEAD>"
response.write "<BODY bgcolor=""#FFFFFF""><br><br><center>"

'------------------------------------------------------------
response.write "<form action=""" & file & """ method=post>"
response.write "<b><font face=verdana size=3 color=""#008080""><u>Total Database Control</u></font></b><br><br>"
response.write "<font face=Verdana,Arial size=2><b>Database Name: </b></font>"
response.write "<select name=""databasename"">"
For i = 0 to uBound(database_list)
If database_list(i) = Request("databasename") Then
    response.write "<option value=""" & database_list(i) & """ selected>" & database_list(i)
Else
    response.write "<option value=""" & database_list(i) & """>" & database_list(i)
End If
Next
response.write "</select> "
response.write "<input type=submit name=GoData



相關文章

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。