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

80酷酷网    80kuku.com

  函数|语句<!--#include file="conn.asp" -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<%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="<P>"&w&"<p>"&"update:"&"
"&"update your_table set "& Join(my_array,",")&"where 条件"&"<p>"&"insert:"&"
"&"insert into your_table ("&w&")values("&Join(my_array1,",")&")"


End Function
response.write e(rsname)%>
</body>
</html>

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: