使用方法:保存為asptools.hta然后再運(yùn)行
代碼如下:
<!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=柳永法 />
<title>asp輔助工具</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 />
登錄名:<input type=text name=userid size=10 style=border:1px solid green value=sa />
密碼:<input type=password name=pwd size=10 style=border:1px solid green value=yongfa365 />
數(shù)據(jù)庫(kù)名:<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
('mssql') value=連接sql數(shù)據(jù)庫(kù) />
<input type=button id=btnfromfile onclick=txtfile.click() value=連接access數(shù)據(jù)庫(kù) style=border:1px solid
green />
<span id=tables ></span>
<hr />
模板:
<input type=text id=opt value= size=40 />
<select size=1 id=fz onchange=opt.value=this.value style=width:200px></select>
<input name=button type=button id=button onclick=c() value=轉(zhuǎn)換 style=border:1px solid green>
<hr />
<textarea id=s rows=10 cols=80 style=width:98%></textarea>
<input type=button onclick=madesql() value=生成sql語(yǔ)句 style=border:1px solid green />
<textarea id=d rows=10 cols=80 style=width:98%></textarea>
</div>
<pre id=sqldemo style=display:none intro=通用建表結(jié)構(gòu)>
--通用建表結(jié)構(gòu)
create table [dbo].[tablename] (
[id] int primary key identity(1,1),--id,主鍵,自動(dòng)號(hào)
[txttitle] varchar(255),--標(biāo)題
[txtcontent] text,--內(nèi)容
[puttime] datetime default (getdate()),--提交時(shí)間
[moditime] datetime default (getdate()),--修改時(shí)間
[hits] int default (0),--點(diǎn)擊數(shù)
[flags] int default (0) ,--標(biāo)識(shí)
[orderid] int default (0),--排序號(hào)
)
</pre>
<pre id=sdemo style=display:none intro=初始源測(cè)試數(shù)據(jù)>
username
password
sex
truename
age
tel
msn
</pre>
<pre id=fzdemo style=display:none intro=輔助輸入>
輔助輸入
rs($1) = request($1)
rs($1) = saferequest($1)
$1 = request($1)
$1 = saferequest($1)
<tr><td>$1:</td><td><input type=text name=$1 size=20></td></tr>
</pre>
<hr />
建議查看源文件然后保存為asptools.hta然后再運(yùn)行
<script language=vbscript type=text/vbscript>
self.focus()
self.resizeto 620, 520
'初始化數(shù)據(jù)
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
'程序運(yùn)行時(shí)的一些函數(shù)
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 '定義全局變量,避免重復(fù)鏈接數(shù)據(jù)庫(kù)。
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>==請(qǐng)選擇
表名==</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 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 & 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>
</html>