ASP auxiliary tool (HTA)

Source: Internet
Author: User

Usage: Save As asptools. HTA and then run CopyCode The Code is as follows: <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
Transitional. DTD ">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Meta name = "author" content = "Liu yongfa"/>
<Title> Asp auxiliary tool </title>
<Style> body {font-size: 12px} </style>
<HTA: Application
Id = "asptools"
Applicationname = "asptools"
Scroll = "no"
Singleinstance = "yes"
Windowstate = "normal"
>
</Head>
<Body>
<Div>
<Input type = "file" id = "txtfile" onchange = "createtableselect ('access')" style = "display: none"/>
IP: <input type = "text" name = "ip" size = "16" style = "border: 1px solid green" value = ". \ sql2005"/>
Login Name: <input type = "text" name = "userid" size = "10" style = "border: 1px solid green" value = "sa"/>
Password: <input type = "password" name = "PWD" size = "10" style = "border: 1px solid green" value = "yongfa365"/>
Database Name: <input type = "text" name = "dbname" size = "10" style = "border: 1px solid green" value = "hb605-8-8"/> <br/>
<Input name = "button2" type = "button" id = "button2" style = "border: 1px solid green" onclick = "createtableselect
('SQL') "value =" connect to 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:







<PRE id = "sqldemo" style = "display: none" intro = "common table creation structure">
-- General table creation Structure
Create Table [DBO]. [tablename] (
[ID] int Primary Key Identity (1, 1), -- id, primary key, automatic number
[Txttitle] varchar (255), -- title
[Txtcontent] Text, -- Content
[Puttime] datetime default (getdate (), -- submission time
[Moditime] datetime default (getdate (), -- modify time
[Hits] int default (0), -- number of clicks
[Flags] int default (0), -- ID
[Orderid] int default (0), -- Order 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 = "secondary input">
Auxiliary Input
RS ("$1") = request ("$1 ")
RS ("$1") = saferequest ("$1 ")
$1 = request ("$1 ")
$1 = saferequest ("$1 ")
<Tr> <TD> $1: </TD> <input type = "text" name = "$1" size = "20"> </TD> </tr>
</PRE>

<HR/>
We recommend that you view the source file, save it as asptools. HTA, and then run

<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

'ProgramRuntime functions

Function C ()
Ss = Split (S. Value, vbcrlf)
For each SSS in SS
If SSS <> "" Then STR = STR & replace (OPT. value, "$1", SSS) & vbcrlf
Next
D. value = Str
End Function

Dim xcat' defines global variables to avoid repeated connection to the database.

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> = 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
End if
Next
S. value = left (STR, Len (STR)-2)
End Function

Function madesql ()
Yongfa365fields = Split (S. Value, vbcrlf)
Yongfa365code2 = ""
For each 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

Tempvalue = join (yongfa365fields, ") &" "','" "& RS (""")
Yongfa365code2 = yongfa365code2 & "conn. Execute" "insert into Info (" & join (yongfa365fields, ",") & ") Values
('"" & RS ("& tempvalue &") & ""') "& vbcrlf

Tempvalue = join (yongfa365fields ,"&""','""&")
Yongfa365code2 = yongfa365code2 & "conn. Execute" "insert into Info (" & join (yongfa365fields, ",") & ") Values
('"&" & Tempvalue & "&" "')" "& 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>
</Html>

To prevent errors, we recommend Packaging

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.