自己寫的部分實用的程式碼

javaprogramers發表於2006-05-13

news.asp
<%
 set rs server.createobject("adodb.recordset")
sql="select * from neixun order by id desc"
rs.open sql ,conn,1,3
%>
新聞:
<% do while not rs.eof %>
<a href =neixun.asp?id=<% = rs("id") %>><% = trim(rs("title")) %>
<%
rs.movenext
loop
%>
neixun.asp
<%
id=request.querystring("id")
set rs=server.createobject("adodb.recordset")
sql="select * from neixun where id="&id
rs.open sql,conn,1,3
%>
新聞標題:<% = rs("title") %>
新聞內容:<% = rs("news" ) %>

自定義列

1.
<asp:templatecolumn headertext="新聞動態" sortexpression="sitename">
 <itemtemplate>
 <asp:hyperlink text='<%#container.dataitem("newtitle")%>' navigateurl='<%#"news.aspx?link_id="&container.dataitem(link_id)%>' target="_blank" runat="server">
 </itemtemplate>
</asp:templatecolumn>
2.
news.aspx
dim strsql as string
strsql="select * from link where link_id="&request.querystring("link_id")
dim cmd as new oledbcommand ( strsql,conn)
conn.open

dim dr as oledbdatareader=cmd.executereader()
dr.read()
message.text&= "新聞標題:"&dr.item("newtitle")
message.text&="<br>新聞內容:"&dr.item("news")
conn.close()

NET使用者系統
dim conn as string
conn=configurationsettings.appsettings("strconn")
dim strsql as string
strsql="selct * from users where username='"&username.text&"' and mypassword = '"&password.text&"' "

dim cmd as newoledbcommand(strsql,conn)
conn.open( )

dim dr as oledbdatareader=cmd.executereader( )

if dr.read( )=ture  then
 conn.close( )
 formsauthentication.redirectformloginpage(username.text,ture)
else
 conn.close( )
 respose.write(" 您的使用者名稱或密碼錯誤了")
end if

相關文章