asp产生表单,用来生成提交的代码
[
2008/12/25 11:43 | by Else ]
2008/12/25 11:43 | by Else ]
asp产生表单,用来生成提交的代码
Set showtable_cmd = Server.CreateObject ("ADODB.Command")
showtable_cmd.ActiveConnection = MM_connDB_STRING
showtable_cmd.CommandText = "SELECT INFORMATION_SCHEMA.COLUMNS.*, COL_LENGTH('"&tablename&"', INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME) AS COLUMN_LENGTH, COLUMNPROPERTY(OBJECT_ID('"&tablename&"'), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsComputed') AS IsComputed, COLUMNPROPERTY(OBJECT_ID('"&tablename&"'), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsIdentity') AS IsIdentity, COLUMNPROPERTY(OBJECT_ID('"&tablename&"'), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsRowGuidCol') AS IsRowGuidCol, ExtendedProperties.Value AS ProgrammaticAlias FROM INFORMATION_SCHEMA.COLUMNS LEFT JOIN ::fn_listextendedproperty('ProgrammaticAlias', 'user', 'dbo', 'table', '"&tablename&"', 'column', default) AS ExtendedProperties ON INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME = ExtendedProperties.objName COLLATE Chinese_PRC_CI_AS WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = '"&tablename&"'"
showtable_cmd.Prepared = true
Set showtable_cmd = Server.CreateObject ("ADODB.Command")
showtable_cmd.ActiveConnection = MM_connDB_STRING
showtable_cmd.CommandText = "SELECT INFORMATION_SCHEMA.COLUMNS.*, COL_LENGTH('"&tablename&"', INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME) AS COLUMN_LENGTH, COLUMNPROPERTY(OBJECT_ID('"&tablename&"'), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsComputed') AS IsComputed, COLUMNPROPERTY(OBJECT_ID('"&tablename&"'), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsIdentity') AS IsIdentity, COLUMNPROPERTY(OBJECT_ID('"&tablename&"'), INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME, 'IsRowGuidCol') AS IsRowGuidCol, ExtendedProperties.Value AS ProgrammaticAlias FROM INFORMATION_SCHEMA.COLUMNS LEFT JOIN ::fn_listextendedproperty('ProgrammaticAlias', 'user', 'dbo', 'table', '"&tablename&"', 'column', default) AS ExtendedProperties ON INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME = ExtendedProperties.objName COLLATE Chinese_PRC_CI_AS WHERE INFORMATION_SCHEMA.COLUMNS.TABLE_NAME = '"&tablename&"'"
showtable_cmd.Prepared = true
asp導出excel的文件,附加php的方法
[
2008/09/10 15:53 | by Else ]
2008/09/10 15:53 | by Else ]
<% Response.ContentType = "application/vnd.ms-excel" %>
<table width="164" height="61" border="1">
<tr>
<td align="center">編號</td>
<td align="center">姓名</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">Else</td>
</tr>
</table>
<table width="164" height="61" border="1">
<tr>
<td align="center">編號</td>
<td align="center">姓名</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">Else</td>
</tr>
</table>
看asp代碼的部分是不是很簡單?
相對而言 php的導成excel的代碼
asp的offset的一个go to page
[
2008/07/06 14:34 | by Else ]
2008/07/06 14:34 | by Else ]
<%
if request.QueryString("page")<>"" then
Recordset1_last=request.QueryString("page")*MM_size
offset=Recordset1_last-MM_size
url="?offset="&offset
response.Redirect(url)
end if
%>
if request.QueryString("page")<>"" then
Recordset1_last=request.QueryString("page")*MM_size
offset=Recordset1_last-MM_size
url="?offset="&offset
response.Redirect(url)
end if
%>
这里放入代码是不破坏原来的结构
<div>总数<%=(Recordset1_total)%> 共<%=Recordset1_total/MM_size%>页 当前第<%=(Recordset1_last/MM_size)%>页 <a href="<%=MM_moveFirst%>">首页</a> <a href="<%=MM_movePrev%>">上一页</a> <a href="<%=MM_moveNext%>">下一页</a> <a href="<%=MM_moveLast%>">最后一页</a>
<label>
<input name="page" type="text" id="page" value="<%=(Recordset1_last/MM_size)%>" size="5" />
<input name="button" type="submit" id="button" onclick="window.location.href='?page='+page.value" value="go" />
</label>
fist<%=(Recordset1_first)%> last<%=(Recordset1_last)%></div>
这里是主要分页的信息
内详
[codes=vb] sql="select * from tableaaa order by id"
rs.open sql,conn,1,1
dim aitem()
dim ysss()
ccc1=rs.recordcount
redim aitem(ccc1)
redim ysss(ccc1)
ii=1
rs.movefirst
for ii=1 to ccc1
aitem(ii)=rs("item_name")
ysss(ii)=rs("state1")
rs.movenext
next
rs.close[/codes]
rs.open sql,conn,1,1
dim aitem()
dim ysss()
ccc1=rs.recordcount
redim aitem(ccc1)
redim ysss(ccc1)
ii=1
rs.movefirst
for ii=1 to ccc1
aitem(ii)=rs("item_name")
ysss(ii)=rs("state1")
rs.movenext
next
rs.close[/codes]
<% For Each cValue in Request.Form %>
<%=cValue%>
<%=Request.Form(cValue)%>'显示值
<% Next %>
<%=cValue%>
<%=Request.Form(cValue)%>'显示值
<% Next %>
for each x in rs.Fields
strLine= strLine & x.value & chr(9)
next
帮朋友改了点东西,留点代码做纪念!
strLine= strLine & x.value & chr(9)
next
jmail的認證方式
[
2008/04/21 15:28 | by Else ]
2008/04/21 15:28 | by Else ]
[codes=vb] set mymail=server.CreateObject("jmail.message")
mymail.MailServerPassWord ="pass" '发信授权邮件密码
mymail.MailServerUserName ="who@qq.com" '发信授权邮件名称
mymail.ContentType = "text/html" '(是否支持html,如不要就去掉此行)
mymail.Charset="utf-8" '使用字符集,不用改的
mymail.AddRecipient "to@qq.com" '收件人邮箱
mymail.Body= "您好86,...." '邮件正文
mymail.From="from@test.com" '发件人邮箱
mymail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
mymail.Subject="你好吗?" '邮件标题
mymail.Send "mail.qq.com",false '邮件发送服务器
set mymail = nothing [/codes]
mymail.MailServerPassWord ="pass" '发信授权邮件密码
mymail.MailServerUserName ="who@qq.com" '发信授权邮件名称
mymail.ContentType = "text/html" '(是否支持html,如不要就去掉此行)
mymail.Charset="utf-8" '使用字符集,不用改的
mymail.AddRecipient "to@qq.com" '收件人邮箱
mymail.Body= "您好86,...." '邮件正文
mymail.From="from@test.com" '发件人邮箱
mymail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
mymail.Subject="你好吗?" '邮件标题
mymail.Send "mail.qq.com",false '邮件发送服务器
set mymail = nothing [/codes]
asp command語句裡的兩個sql
[
2008/04/09 10:09 | by Else ]
2008/04/09 10:09 | by Else ]
[codes=vb]
'刪除回復貼
If (Request.querystring("del")="ok") Then
'刪除權限,用來觸發ajax的error
if session("bbsadmin")=1 then
dim delrs
Set MM_delCmd = Server.CreateObject ("ADODB.Command")
MM_delCmd.ActiveConnection = MM_conn_STRING
SelectSQL = "Select * from bbs WHERE id ="&Request.form("id")
MM_delCmd.CommandText =SelectSQL
MM_delCmd.Prepared = true
set delrs = MM_delCmd.Execute
if delrs.Fields.Item("cc").Value<>"" then
DeleteFile(server.MapPath("../obj/"&delrs.Fields.Item("cc").Value))
end if
MM_delCmd.CommandText = "DELETE FROM bbs WHERE id ="&Request.form("id")&""
MM_delCmd.Prepared = true
MM_delCmd.Execute
MM_delCmd.ActiveConnection.Close
response.Write("刪除成功")
response.End()
end if
End If
[/codes]這個是刪除的,我試了一個insert into 和一個update set 這個就不行了!
'刪除回復貼
If (Request.querystring("del")="ok") Then
'刪除權限,用來觸發ajax的error
if session("bbsadmin")=1 then
dim delrs
Set MM_delCmd = Server.CreateObject ("ADODB.Command")
MM_delCmd.ActiveConnection = MM_conn_STRING
SelectSQL = "Select * from bbs WHERE id ="&Request.form("id")
MM_delCmd.CommandText =SelectSQL
MM_delCmd.Prepared = true
set delrs = MM_delCmd.Execute
if delrs.Fields.Item("cc").Value<>"" then
DeleteFile(server.MapPath("../obj/"&delrs.Fields.Item("cc").Value))
end if
MM_delCmd.CommandText = "DELETE FROM bbs WHERE id ="&Request.form("id")&""
MM_delCmd.Prepared = true
MM_delCmd.Execute
MM_delCmd.ActiveConnection.Close
response.Write("刪除成功")
response.End()
end if
End If
[/codes]這個是刪除的,我試了一個insert into 和一個update set 這個就不行了!
asp常用的兩個email組件用法
[
2008/04/07 16:51 | by Else ]
2008/04/07 16:51 | by Else ]
JMail.SMTPMail
<%
'文件測試中文亂碼問題
'測試時間:2007.12.03 - 第二次測試
'response.codepage="950"
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ContentType="text/html"
'JMail.Encoding = "base64" ' 有試過注釋此行,問題依舊
jmail.Charset="BIG5"
'jmail.ContentType = "text/html;charset=BIG5"
jmail.ISOEncodeHeaders = false
JMail.Sender = "testi#sina.com" ' 發送人郵箱
JMail.SenderName = "這個中中文" ' 發送人姓名
JMail.AddRecipient("test#qq.com") ' 收件人郵箱
JMail.Body = "這個是內容,在測試一次,這個是註冊信息,不是垃圾 email,我們做個測試,測試的內容" ' 郵件正文
JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
arrFile = Split(fileItem1,"$$")
'For i = 0 To Ubound(arrFile)-1
'JMail.AddAttachment(arrFile(i)) ' 多附件添加,單一附件也試過,問題依舊
'Next
JMail.Subject = "你的註冊信息,請注意接收,接收的email 增加了encoding,刪除了codepage 去了 iso的標準" ' 郵件標題
JMail.Execute
JMail.Close
Set JMail = Nothing
%>
'文件測試中文亂碼問題
'測試時間:2007.12.03 - 第二次測試
'response.codepage="950"
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ContentType="text/html"
'JMail.Encoding = "base64" ' 有試過注釋此行,問題依舊
jmail.Charset="BIG5"
'jmail.ContentType = "text/html;charset=BIG5"
jmail.ISOEncodeHeaders = false
JMail.Sender = "testi#sina.com" ' 發送人郵箱
JMail.SenderName = "這個中中文" ' 發送人姓名
JMail.AddRecipient("test#qq.com") ' 收件人郵箱
JMail.Body = "這個是內容,在測試一次,這個是註冊信息,不是垃圾 email,我們做個測試,測試的內容" ' 郵件正文
JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
arrFile = Split(fileItem1,"$$")
'For i = 0 To Ubound(arrFile)-1
'JMail.AddAttachment(arrFile(i)) ' 多附件添加,單一附件也試過,問題依舊
'Next
JMail.Subject = "你的註冊信息,請注意接收,接收的email 增加了encoding,刪除了codepage 去了 iso的標準" ' 郵件標題
JMail.Execute
JMail.Close
Set JMail = Nothing
%>
ADODB.Command
[
2008/03/17 14:20 | by Else ]
2008/03/17 14:20 | by Else ]
Set rslist_cmd = Server.CreateObject ("ADODB.Command")
<%
' *** Delete Record: construct a sql delete statement and execute it
If (CStr(Request("act")) = "del") Then
' execute the delete
Set MM_delCmd = Server.CreateObject ("ADODB.Command")
MM_delCmd.ActiveConnection = MM_conn_STRING
MM_delCmd.CommandText = "DELETE FROM dbo.jpcusertable WHERE id = ?"
MM_delCmd.Parameters.Append MM_delCmd.CreateParameter("param1", 5, 1, -1, Request.QueryString("id")) ' adDouble
MM_delCmd.Execute
MM_delCmd.ActiveConnection.Close
' append the query string to the redirect URL
Response.Redirect("client.asp")
End If
%>
' *** Delete Record: construct a sql delete statement and execute it
If (CStr(Request("act")) = "del") Then
' execute the delete
Set MM_delCmd = Server.CreateObject ("ADODB.Command")
MM_delCmd.ActiveConnection = MM_conn_STRING
MM_delCmd.CommandText = "DELETE FROM dbo.jpcusertable WHERE id = ?"
MM_delCmd.Parameters.Append MM_delCmd.CreateParameter("param1", 5, 1, -1, Request.QueryString("id")) ' adDouble
MM_delCmd.Execute
MM_delCmd.ActiveConnection.Close
' append the query string to the redirect URL
Response.Redirect("client.asp")
End If
%>
asp 的dw生成的代码,不在看不懂,
[
2008/03/11 17:15 | by Else ]
2008/03/11 17:15 | by Else ]
<%
Dim news_rs__MMColParam
news_rs__MMColParam = "1"
If (Session("num") <> "") Then
news_rs__MMColParam = Session("num")
End If
%>
<%
Dim news_rs
Dim news_rs_cmd
Dim news_rs_numRows
Set news_rs_cmd = Server.CreateObject ("ADODB.Command")
news_rs_cmd.ActiveConnection = MM_conn_STRING
news_rs_cmd.CommandText = "SELECT * FROM dbo.ruby WHERE num = ? ORDER BY newsId DESC"
news_rs_cmd.Prepared = true
news_rs_cmd.Parameters.Append news_rs_cmd.CreateParameter("param1", 200, 1, 100, news_rs__MMColParam) ' adVarChar
Set news_rs = news_rs_cmd.Execute
news_rs_numRows = 0
%>
Dim news_rs__MMColParam
news_rs__MMColParam = "1"
If (Session("num") <> "") Then
news_rs__MMColParam = Session("num")
End If
%>
<%
Dim news_rs
Dim news_rs_cmd
Dim news_rs_numRows
Set news_rs_cmd = Server.CreateObject ("ADODB.Command")
news_rs_cmd.ActiveConnection = MM_conn_STRING
news_rs_cmd.CommandText = "SELECT * FROM dbo.ruby WHERE num = ? ORDER BY newsId DESC"
news_rs_cmd.Prepared = true
news_rs_cmd.Parameters.Append news_rs_cmd.CreateParameter("param1", 200, 1, 100, news_rs__MMColParam) ' adVarChar
Set news_rs = news_rs_cmd.Execute
news_rs_numRows = 0
%>
记得以前刚刚接触的时候,有点看不懂,但现在喜欢上这样的一个格式,时间上有很大上升的空间,
现在机子好一点,将会学到更多!
编程的机子,也不会是垃圾的机子
asp关于 utf-8的问题,
[
2008/03/11 17:11 | by Else ]
2008/03/11 17:11 | by Else ]
试了几个,下面的是我比较喜欢的
在限制session的时候,这个还是比较方便 的
这样可以确保提示的非英文不是乱码
php方面就是header了,
最近回去,好像是位子不是很好,所以都没有写些什么了
在限制session的时候,这个还是比较方便 的
response.Charset="utf-8"
这样可以确保提示的非英文不是乱码
php方面就是header了,
最近回去,好像是位子不是很好,所以都没有写些什么了





