小弟急需商城和论坛的源代码,有谁可以给个好点的地址呀?
网上的那些好象都不太好用,总是链接方面出现问题。谢谢各位了。
我给一点代码,你自己看看,index.aspx
<%@ Page Language="vb" Debug="True" %>
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<html>
<head><title>BBS</title>
</head>
<body bgcolor="#FFFFFF">
<h2 align="center">讨论板</h2>
<form runat="server">
<asp:DataGrid runat="server" ID="MyGrid"
AllowPaging="true"
PageSize="10"
OnPageIndexChanged="ChangePage"
PagerStyle-Mode="NumericPages"
PagerStyle-HorizontalAlign="Right"
AlternatingItemStyle-BackColor="#FFFFCC"
GridLines="None"
border="1"
CellSpacing="0"
CellPadding="2"
AutoGenerateColumns="false"
width="100%"
>
<columns>
<asp:BoundColumn DataField="TITLES_DATE" HeaderText="日期" />
<asp:BoundColumn DataField="TITLES_NAME" HeaderText="作者" />
<asp:BoundColumn DataField="TITLES_NUM" HeaderText="则数" />
<asp:HyperLinkColumn DataTextField="TITLES_SUBJECT"
HeaderText="主题"
DataNavigateUrlField="TITLES_ID"
DataNavigateUrlFormatString="Detail.aspx?TITLES_ID={0}" />
</columns>
</asp:DataGrid>
<table width="100%" height="192" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td colspan="2">发起讨论主题</td>
</tr>
<tr>
<td width="31%" align="right">姓名:</td>
<td width="69%">
<asp:TextBox runat="server" ID="TITLES_NAME" />
<asp:RequiredFieldValidator runat="server" Text="*" ControlToValidate="TITLES_NAME" /></td>
</tr>
<tr>
<td align="right">EMAIL:</td>
<td>
<asp:TextBox runat="server" ID="TITLES_EMAIL" />
<asp:RequiredFieldValidator runat="server" Text="*" ControlToValidate="TITLES_EMAIL" />
<asp:RegularExpressionValidator runat="server" ControlToValidate="TITLES_EMAIL" Text="EMAIL要符合规范"
ValidationExpression=".{1,}@.{3,}" Display="Dynamic" />
</td>
</tr>
<tr>
<td align="right">主题:</td>
<td><asp:TextBox runat="server" ID="TITLES_SUBJECT" Size="60" />
<asp:RequiredFieldValidator runat="server" Text="*" ControlToValidate="TITLES_SUBJECT" />
</td>
</tr>
<tr>
<td align="right">内容:</td>
<td><asp:TextBox ID="TITLES_CONTENT" runat="server" Rows="6" Columns="60" TextMode="MultiLine" />
<asp:RequiredFieldValidator runat="server" Text="*" ControlToValidate="TITLES_CONTENT" />
</td>
</tr>
<tr align="center">
<td colspan="2"><asp:Button ID="Button" Text="发表主题" runat="server" OnClick="Send_Click" /></td>
</tr>
</table>
</form>
</body>
</html>
<script language="vb" runat="server">
Dim Provider = "Provider=Microsoft.Jet.OLEDB.4.0"
Dim DataBase = "Data Source=" & Server.MapPath( "data/)#data.mdb" )
Sub Page_Load(send As Object, E As EventArgs)
If Not IsPostBack Then
OpenDataBase_And_BindToDataGrid()
End If
End Sub
Sub ChangePage(sender As Object, E As DataGridPageChangedEventArgs)
MyGrid.CurrentPageIndex = E.NewPageIndex
OpenDataBase_And_BindToDataGrid()
End Sub
Sub OpenDataBase_And_BindToDataGrid()
Dim Conn As OleDbConnection, Adpt As OleDbDataAdapter
Dim Ds As DataSet, SQL As String, I As Integer
Dim Table1 As DataTable
Conn = New OleDbConnection( Provider & ";" & DataBase )
Conn.Open()
SQL = "Select * From BBS_TITLES Order By Titles_LASTPOSTDATE Desc"
Adpt = New OleDbDataAdapter( SQL, Conn )
Ds = New DataSet()
Adpt.Fill(Ds, "BBS_TITLES")
Table1 = Ds.Tables( "BBS_TITLES" )
Table1.Columns.Add(New DataColumn("TITLES_DATE", GetType(String)))
For I = 0 To Table1.Rows.Count-1
Dim D1 As Date = Table1.Rows(I).Item("TITLES_CREATEDATE")
Dim D2 As Date = Table1.Rows(I).Item("TITLES_LASTPOSTDATE")
Table1.Rows(I).Item("TITLES_DATE") = Format( D1, "MM/dd") & "-" & Format( D2, "MM/dd")
Next
MyGrid.DataSource = Table1.DefaultView
MyGrid.DataBind()
Conn.Close()
End Sub
Sub Send_Click(sender As Object, E As EventArgs)
Dim Conn As OleDbConnection,Cmd As OleDbCommand
Dim SQL As String
Conn = New OleDbConnection( Provider & ";" & DataBase )
Conn.Open()
SQL = "Insert Into BBS_TITLES (TITLES_NAME, TITLES_EMAIL, TITLES_SUBJECT, TITLES_CONTENT, TITLES_NUM) Values (?, ?, ?, ?, ?)"
Cmd = New OleDbCommand(SQL, Conn)
Cmd.Parameters.Add( New OleDbParameter("TITLES_NAME", OleDbType.Char,255))
Cmd.Parameters.Add( New OleDbParameter("TITLES_EMAIL", OleDbType.Char,255))
Cmd.Parameters.Add( New OleDbParameter("TITLES_SUBJECT", OleDbType.VarChar))
Cmd.Parameters.Add( New OleDbParameter("TITLES_CONTENT", OleDbType.VarChar))
Cmd.Parameters.Add( New OleDbParameter("TITLES_NUM", OleDbType.Integer))
Cmd.Parameters("TITLES_NAME").Value = TITLES_NAME.Text
Cmd.Parameters("TITLES_EMAIL").Value = TITLES_EMAIL.Text
Cmd.Parameters("TITLES_SUBJECT").Value = TITLES_SUBJECT.Text
Cmd.Parameters("TITLES_CONTENT").Value = TITLES_CONTENT.Text
Cmd.Parameters("TITLES_NUM").Value = 0
Cmd.ExecuteNonQuery()
Conn.Close()
OpenDataBase_And_BindToDataGrid()
End Sub
</script>