在ASP中是这样的:
Set Rs=Conn.Execute("Select top 1 * From Table")
For i=0 To Rs.Fields.Count - 1
 Response.Write Rs.Fields(i).Name & "=Rs(""" & Rs.Fields(i).Name & """)" & vbCrLf
Next
Response.End


Call print_sql("shjia")
Sub print_sql(Table)
 dim Conn,Rs,strSQL
 lSqlConn = Application("Connstr")
 Set Conn = Server.CreateObject("ADODB.Connection")
 Conn.Open lSqlConn

  Set Rs=Conn.Execute("Select top 1 * From "&Table)
  
  Response.Write "Dim  "
  
  For i=0 To Rs.Fields.Count - 1
   If i=0 Then
    Response.Write  Rs.Fields(i).Name
   Else
    Response.Write "," & Rs.Fields(i).Name   
   End If
  Next
  
  Response.Write vbCrLf
  Response.Write vbCrLf
  Response.Write vbCrLf
  
  For i=0 To Rs.Fields.Count - 1
   Response.Write Rs.Fields(i).Name & "=Rs(""" & Rs.Fields(i).Name & """)" & vbCrLf
  Next
  
  Response.Write vbCrLf
  Response.Write vbCrLf
  Response.Write vbCrLf
  
  For i=0 To Rs.Fields.Count - 1
   Response.Write "Rs(""" & Rs.Fields(i).Name & """)=" & Rs.Fields(i).Name & vbCrLf
  Next
  
  Response.Write vbCrLf
  Response.Write vbCrLf
  Response.Write vbCrLf
  
  For i=0 To Rs.Fields.Count - 1
   Response.Write Rs.Fields(i).Name & "=Request(""" & Rs.Fields(i).Name & """)" & vbCrLf
  Next
  
  Response.Write vbCrLf
  Response.Write vbCrLf
  Response.Write vbCrLf
  
  For i=0 To Rs.Fields.Count - 1
   Response.Write Rs.Fields(i).Name & "=Request.from(""" & Rs.Fields(i).Name & """)" & vbCrLf
  Next

 Rs.close
 Set Rs=nothing
 conn.close
 Set conn=nothing
 Response.End
End Sub 

<%
Function Replacehtml(Textstr)
Dim Str,re
Str=Textstr
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
're.Pattern="<(.[^>]*)>"
re.Pattern="\<[^>]+()\>"

Str=re.Replace(Str, "")
Set Re=Nothing
Replacehtml=Str
End Function


'截取前n个字符
Function CutString(str, n,s_More)
  if n<0 then n=0
    If Len(str) <= n / 2 Then
     CutString = str
    Else
     Dim TStr
     Dim l, t, c
     Dim i
     l = Len(str)
     t = l
     TStr = ""
     t = 0
     For i = 1 To l
      c = Asc(Mid(str, i, 1))
      If c < 0 Then c = c + 65536
      If c > 255 Then
       t = t + 2
      Else
       t = t + 1
      End If
      If t > n Then
    TStr = TStr & "..."
    Exit For
   End If
      TStr = TStr & (Mid(str, i, 1))
     Next
     If l > Len(TStr) Then
         CutString = TStr & s_More
     Else
         CutString = TStr
     End If
    End If
End Function

'返回字符串的字符长度
Function StringLen(str)
 Dim l, t, c
 Dim i
 l = Len(str)
 t = 0
 For i = 1 To l
  c = Asc(Mid(str, i, 1))
  if c<0 or c>255 then
     t = t + 2
   else
     t = t + 1
   end if
 next

 
 'For i = 1 To l
 ' c = Asc(Mid(str, i, 1))
 ' If c < 0 Then c = c + 65536
 ' If c > 255 Then
 '  t = t + 2
 ' Else
 '  t = t + 1
 ' End If
 'Next
 StringLen = t
End Function

%>

posted on 2006-09-08 13:42  罗明超  阅读(205)  评论(0编辑  收藏  举报