dvbbs
收藏本页
联系我们
论坛帮助
dvbbs

堕落街论坛休闲之乐游戏体育 → 留言本代码


  共有192人关注过本帖树形打印

主题:留言本代码

帅哥哟,离线,有人找我吗?
万金油
  1楼 个性首页 | 博客 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:学前 主题:9 精华:0 贴子:29 排名:0 威望:0 排名:0 注册:2005/1/24 12:22:00 近访:2005/3/16 23:37:00
留言本代码  发贴心情 Post By:2005/3/4 0:12:15

<%@ Page Language="VB" Debug="true" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs) ' bind the data grid to the data DataList1.DataSource=createdataview("Northwind.mdb","guestbook") DataList1.DataBind() End Sub function createdataview( db as string , table as string ) as dataview Dim connectionString As String Dim queryString As String Dim data As New DataSet() Dim dbConnection As OleDbConnection Dim dataAdapter As OleDbDataAdapter ' set the connection and query details connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=" & Server.MapPath(db) queryString = "SELECT*FROM"&table ' open the connection and set the command dbConnection = New OledbConnection(connectionString) dataAdapter = New OledbDataAdapter(queryString, dbConnection) ' fill the dataset with the data Dim ds as DataSet = New DataSet() dataAdapter.Fill(ds,table) createdataview = new DataView(ds.Tables(table)) end function Sub DataList_ItemCommand(Sender As Object, E As DataListCommandEventArgs) select case e.CommandSource.Text case "I want to say" foot.visible = true case "read the content" DataList1.SelectedIndex = E.Item.ItemIndex case "close" DataList1.SelectedIndex = -1 end select DataList1.DataSource=createdataview("Northwind.mdb","guestbook") DataList1.DataBind() end sub Sub LinkButton2_Click(sender As Object, e As EventArgs) foot.Visible = false End Sub Sub LinkButton1_Click(sender As Object, e As EventArgs) Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\BegASPNET11\"& _ "lyb\Northwind.mdb" Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString) Dim queryString As String = "INSERT INTO [guestbook] ([username], [post_time], [content]) VALUES (Username.Val"& _ "ue, DataTime.Now, Content.Value)" Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection dbConnection.Open dbCommand.ExecuteNonQuery dbConnection.Close Message.InnerHtml="<b>OK!</b>" foot.Visible = false End Sub

</script> <html> <head> <title>guestbook</title> </head> <body> <div id="Message" runat="server"> </div> <h3>留言本 </h3> <form runat="server"> <asp:DataList id="DataList1" runat="server" OnItemCommand="DataList_ItemCommand"> <Headertemplate> <asp:LinkButton id="Tosay" runat="server" Text="I want to say" /> &nbsp; <a href="lyb.aspx">flash</a> </Headertemplate> <ITEMtemplate> <%# Container.DataItem("book_id") %> <%# Container.DataItem("content") %> <asp:LinkButton id="detail" runat="server" Text="read the content" /> </ITEMtemplate> <SELECTEDITEMtemplate> ID:<%# Container.DataItem("book_id") %> <br /> name:<%# Container.DataItem("username") %> <br /> time:<%# Container.DataItem("post_time") %> content:<%# Container.DataItem("content") %> <div align="right"> <asp:LinkButton id="title" runat="server" Text="close"></asp:LinkButton> </div> </SELECTEDITEMtemplate> </asp:DataList> <table id="foot" runat="server" visible="false"> <tbody> <tr> <td> <p> name: <input id="username" type="text" name="username" /> </p> <p> content: </p> <textarea id="content" name="content"></textarea> <asp:LinkButton id="save" onclick="LinkButton1_Click" runat="server">save</asp:LinkButton> <p> <asp:LinkButton id="close" onclick="LinkButton2_Click" runat="server">close</asp:LinkButton> </p> </td> </tr> </tbody> </table> </form> <hr /> <asp:Literal id="Literal1" runat="server"></asp:Literal> <hr /> </body> </html>


支持(0中立(0反对(0回到顶部
帅哥哟,离线,有人找我吗?
万金油
  2楼 个性首页 | 博客 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:学前 主题:9 精华:0 贴子:29 排名:0 威望:0 排名:0 注册:2005/1/24 12:22:00 近访:2005/3/16 23:37:00
  发贴心情 Post By:2005/3/4 0:16:06

数据库Northwind.mdb

表guestbook结构

book_id username post_time content


支持(0中立(0反对(0回到顶部
帅哥哟,离线,有人找我吗?
边走边爱
  3楼 个性首页 | 博客 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 ぁ邊走邊愛ベ
等级:高三 主题:84 精华:0 贴子:1791 排名:1729 威望:4 排名:366 注册:2004/11/10 11:40:00 近访:2008/1/10 17:59:56
  发贴心情 Post By:2005/3/4 13:03:22

安装论坛程序不更好用`````


快乐要有悲伤作陪,雨过应该就有天晴。如果雨后还是雨,如果忧伤之后还是忧伤.请让我们从容面对这离别之后的离别。 微笑地去寻找一个不可能出现的妳。

支持(0中立(0反对(0回到顶部
帅哥哟,离线,有人找我吗?
我最简单
  4楼 个性首页 | 博客 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:高二 主题:80 精华:0 贴子:1037 排名:9684 威望:17 排名:87 注册:2003/11/20 16:10:00 近访:2010/1/17 19:56:52
  发贴心情 Post By:2005/3/4 21:36:27

最好把你的文件名分开注名

并说明安装和配置方法,那样或许好些



      持身涉世,不可随境而迁.须是大火流金而清风穆然,严霜杀物而和气蔼然,阴霾翳空而慧日朗然,洪涛倒海而坻柱屹然,方是宇宙内的真人品.爱是万缘之根,当知割舍.识是众欲之本,要力扫除.作人要脱俗,不可存一矫俗之心;应世要随时,不可起一趋时之念.

<PS:我是流民!>

支持(0中立(0反对(0回到顶部