How to: Save As Asptools.hta and then run
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-
Transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<meta name= "Author" content= "Liu Yong's Law"/>
<title>asp Auxiliary Tools </title>
<style>body{font-size:12px}</style>
Id= "Asptools"
Applicationname= "Asptools"
Scroll= "No"
Singleinstance= "Yes"
Windowstate= "Normal"
>
<body>
<div>
<input type= "File" id= "txtfile" onchange= "Createtableselect (' ACCESS ')" style= "Display:none"/>
Ip:<input type= "text" name= "IP" size= "style=" border:1px solid green "value=" \sql2005
Login name: <input type= "text" name= "UserID" size= "ten" style= "border:1px solid green" value= "sa"/>
Password: <input type= "password" name= "pwd" size= "ten" style= "border:1px solid green" value= "yongfa365"/>
Database name: <input type= "text" name= "dbname" size= "ten" style= "border:1px solid green" value= "hb605-8-8"/><br/>
<input name= "button2" type= button "id=" Button2 "style=" border:1px solid green "onclick=" Createtableselect
(' MSSQL ') ' value= "Connect SQL database"/>
<input type= "button" id= "Btnfromfile" onclick= "Txtfile.click ()" value= "Connect to Access database" style= "border:1px Solid
Green "/>
<span id= "Tables" ></span>
Template:
<input type= "text" id= "opt" "value=" "size="/>
<select size= "1" id= "FZ" onchange= "Opt.value=this.value" style= "width:200px" ></select>
<input name= "button" type= "button" id= "button" onclick= "C ()" value= "Convert" style= "border:1px solid green" >
<textarea id= "s" rows= "cols=" style= "width:98%" ></textarea>
<input type= "button" onclick= "Madesql ()" value= "Generate SQL Statement" style= "border:1px solid green"/>
<textarea id= "D" rows= "cols=" style= "width:98%" ></textarea>
</div>
<pre id= "Sqldemo" style= "Display:none" intro= "universal table Structure" >
--General building table structure
Create Table [dbo]. [TableName] (
[ID] int PRIMARY key identity (1,1),--ID, primary key, auto number
[Txttitle] varchar (255),--title
[txtcontent] Text,--content
[Puttime] DateTime Default (GETDATE ()),--commit time
[Moditime] DateTime Default (GETDATE ()),--modification Time
[Hits] int Default (0),--number of clicks
[Flags] int Default (0),--identification
[OrderID] int Default (0),--sort number
)
</pre>
<pre id= "Sdemo" style= "Display:none" intro= "initial Source test Data" >
UserName
Password
Sex
Truename
Age
Tel
Msn
Qq
Email
</pre>
<pre id= "Fzdemo" style= "Display:none" intro= "Auxiliary input" >
Secondary input
RS ("$") = Request ("$")
RS ("$") = Saferequest ("$")
$ = Request ("$")
$ = saferequest ("$")
<tr><td>$1:</td><td><input type= "Text" name= "$" size= "></td></tr>"
</pre>
It is recommended that you view the source file and save it as Asptools.hta and then run it again
<script language= "VBScript" type= "Text/vbscript" >
Self. Focus ()
Self. Resizeto 620, 520
' Initialize data
S.value = sdemo.innerhtml
Fzs = Split (fzdemo.innerhtml, vbCrLf)
For each opttemp in Fzs
Set o = document.createelement ("option")
O.text = Opttemp
O.value = Opttemp
Fz. Add o
Next
Opt. Value = fz.options (1). Value
' Some functions when the program is running
Function C ()
SS = Split (S.value, vbCrLf)
For each SSS in SS
If sss<> "" Then str = str & Replace (opt. Value, "$", SSS & VbCrLf
Next
D.value = Str
End Function
Dim xCat ' defines global variables and avoids repeating linked databases.
Function Createtableselect (DbType)
Set XCat = CreateObject ("ADOX. Catalog ")
If DbType = "ACCESS" Then
Xcat.activeconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Txtfile.value
ElseIf DbType = "MSSQL" Then
Xcat.activeconnection = "Provider=SQLOLEDB.1; Persist Security info=true; Data source= "& IP. Value & ";
Initial catalog= "& dbname. Value & "; User id= "& Userid.value &"; Password= "& pwd. Value
End If
For each xtable in Xcat.tables
Tabletype = Xtable.type
If Tabletype = "TABLE" Then
tabless = tabless & "<option value= '" & Xtable.name & ">" & xtable.name & "</option>"
End If
Next
tables.innerhtml = "<select name= ' nowtables ' onchange= ' Createfieldselect (" "& DbType &" ") ' ><option >== Please select
Table name ==</option> "& tabless &" </select> "
End Function
Function Createfieldselect (DbType)
Dim Item
For each xtable in Xcat.tables
If xtable.name = Nowtables.value Then
For each Item in Xtable.columns
str = str + item.name & vbCrLf
Next
Exit for
End If
Next
S.value = Left (str, Len (str)-2)
End Function
Function Madesql ()
Yongfa365fields = Split (S.value, vbCrLf)
Yongfa365code2 = ""
For all SQL in Yongfa365fields
If sql<> "" Then strSQL = strSQL & ["& SQL &"] varchar (50), "
Next
strSQL = Left (strSQL, Len (strSQL)-1)
Yongfa365code2 = "Create Table tablename" ("& VbCrLf & Replace (strSQL,", ",", "& VbCrLf) & VbCrLf &") "& VbCrLf
& VbCrLf
Tempvalue = Join (Yongfa365fields, "&" "', '" "& Objitem.")
Yongfa365code2 = yongfa365code2 & "Conn.execute" "INSERT INTO Info (& Join (Yongfa365fields,", ") &") values
(' "" & Objitem. "& Tempvalue &" & "" ")" "& VbCrLf & VbCrLf & VbCrLf
Tempvalue = Join (Yongfa365fields, "" ") &" "," "& RS (" ")
Yongfa365code2 = yongfa365code2 & "Conn.execute" "INSERT INTO Info (& Join (Yongfa365fields,", ") &") values
(' "" & RS ("" "& Tempvalue &" ") &" "" "" "& VbCrLf & VbCrLf & VbCrLf
Tempvalue = Join (Yongfa365fields, "&" "', '" "&")
Yongfa365code2 = yongfa365code2 & "Conn.execute" "INSERT INTO Info (& Join (Yongfa365fields,", ") &") values
(' "& & Tempvalue &" & "" ') "" "& VbCrLf & VbCrLf & VbCrLf
D.value = sqldemo.innerhtml & String (2, vbCrLf) & Yongfa365code2
End Function
Function rereplace (Str, Restrs, RESTRD)
Set re = New RegExp
Re. IgnoreCase = True
Re. Global = True
Re. Pattern = Restrs
Rereplace = Re. Replace (STR, RESTRD)
End Function
</script>
</body>
To prevent errors, special package download address