These days I made several websites for the school and found a problem. Some databases (mostly access, and some msql) encountered problems during design, this causes a lot of data in the database to be redundant, so you need to clean up the database. So I started to write an ASP file cleandata. asp (see the following article for the code ).
The key issue lies in the database problem. I originally had test data on my machine, but I need to modify the data on the network. For the sake of security, our school does not open ftp on the campus network, it is very troublesome for the runway network to be updated without updating data.
So I thought, could I use files locally to access a remote database and perform remote operations?
I didn't pay attention to it at first. I found this thing during code writing:
Objconn. connectionstring
Here, I use "provider = Microsoft. Jet. oledb.4.0; Data Source =" & policcepath
When I write this, I suddenly think of the issue of using cepath. Can I set it to a remote address? For example: http://www.xxx.com/data.mdb
I tested it and failed! But I still don't want to be reconciled. Does it seem OK? Wait for tomorrow and record the following today!
Source code:
<! -- # Include file = "common/webconfig. asp" -->
<! -- # Include file = "common/clsmain. asp" -->
<%
Dim action, datatype
Action = lcase (TRIM (request. querystring ("action ")))
Datatype = lcase (TRIM (request. Form ("datatype ")))
If action = "clear" then
Call cleardata (datatype)
End if
%>
<Form name = "form1" method = "Post" Action = "? Action = clear ">
<Table width = "80%" border = "0" align = "center" cellpadding = "0" cellspacing = "0">
<Tr>
<TD> <Div align = "right"> select clear object: </div> </TD>
<TD> <label>
<Div align = "Left">
<Select name = "datatype">
<Option value = "0"> Level 1 Classification </option>
<Option value = "1"> secondary classification </option>
<Option value = "2"> news content </option>
<Option value = "3"> all </option>
</SELECT>
</Div>
</Label> </TD>
<TD> & nbsp; </TD>
</Tr>
<Tr>
<TD> & nbsp; </TD>
<TD> & nbsp; </TD>
<TD> & nbsp; </TD>
</Tr>
<Tr>
<TD colspan = "2" rowspan = "2"> & nbsp; </TD>
<TD> & nbsp; </TD>
</Tr>
<Tr>
<TD> & nbsp; </TD>
</Tr>
<Tr>
<TD> <label>
<Div align = "center">
<Input type = "Submit" name = "Submit" value = "OK">
</Div>
</Label> </TD>
<TD> <label>
<Div align = "center">
<Input type = "reset" name = "submit2" value = "cancel">
</Div>
</Label> </TD>
<TD> & nbsp; </TD>
</Tr>
</Table>
</Form>
<% Sub cleardata (j)
Dim dsj
Set dsj = new clsdsj
Dsj. DEBUG = true
If not dsj. debug then on error resume next
Dsj. clientconnected
Dim STR (3), MSG
STR (0) = "delete dsj_catalog .*"&_
"From dsj_catalog "&_
"Where "&_
"Catalogid not in (select parentid from dsj_class )"
STR (1) = "delete dsj_class .*"&_
"From dsj_class "&_
"Where "&_
"Parentid not in (select catalogid from dsj_catalog )"
STR (2) = "delete dsj_news .*"&_
"From dsj_news "&_
"Where "&_
"Classid not in (select classid from dsj_class )"
Dim Conn, cmd
Set conn = server. Createobject ("ADODB. Connection ")
Conn. connectiontimeout = 15
'Conn. connectionstring = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath (dbfolder & database)
Dim remotedb
Remotedb = "http://www.xxx.cn/database.mdb"
Conn. connectionstring = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & remotedb
Conn. open ()
Conn. begintrans ()
Set cmd = server. Createobject ("ADODB. Command ")
Cmd. commandtimeout = 15
Cmd. activeconnection = Conn
Cmd. commandtype = 1
Dim I
For I = 0 to 2
If J = 3 then J = I 'ensure that all operations are performed
Cmd. commandtext = STR (j)
Cmd.exe cute ()
If (j <> 3 and j <> I) Then exit for 'ensure that only one execution is performed here
Next
If conn. errors. Count = 0 then
Conn. committrans ()
MSG = "successfully executed"
Else
Conn. rallbacktrans ()
MSG = "error occurred"
End if
Dsj. Alert (MSG)
Set dsj = nothing
End sub
%>