一聚教程网:一个值得你收藏的教程网站

热门教程

今天终于受不了再写长长的SQL语句了,写了这一段,改改可成为SQL语句生成函数

时间:2022-06-30 10:25:15 编辑:袖梨 来源:一聚教程网




Untitled Document



<%Dim rs,sql,rsname
set rs=server.createobject("adodb.recordset")
on error resume next     
    sql="select * from your_table"
    rs.Open sql, conn
    rsname=RS( 0 ).name
for i = 1 to RS.Fields.Count - 1
    'rsname=rsname&chr(9)&RS( i ).name
    rsname=rsname&","&RS( i ).name
next
rsname=rsname&chr(13)
rs.close
set rs=nothing
conn.close
set conn=nothing
Function e(w)
Dim h
Dim my_array,my_array1
my_array=Split(w,",")
my_array1=Split(w,",")
Dim i
For i=0 To UBound(my_array)
my_array(i)=my_array(i)&"="&chr(39)&chr(34)&Chr(38)&my_array(i)&chr(38)&chr(34)&Chr(39)
Next
For i=0 To UBound(my_array)
my_array1(i)=chr(39)&chr(34)&Chr(38)&my_array1(i)&chr(38)&chr(34)&Chr(39)
Next
e="

"&w&"

"&"update:"&"
"&"update your_table set "& Join(my_array,",")&"where 条件"&"

"&"insert:"&"
"&"insert into your_table ("&w&")values("&Join(my_array1,",")&")"
End Function
response.write e(rsname)%>



热门栏目