ASP.NET Computer forum-Message page code

ASP.NET



Computer forum-Message page code

Message.aspx

<%@ Page Language="vb" AutoEventWireup="true" %>
<%@ Import Namespace ="System.Data" %>
<%@ Import Namespace ="System.Data.Oledb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Message</title>
<style type="text/css">
#form1
{
height: 212px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<h4 style="background-color: #CCCFFF">Question:</h4>
<p>
<asp:TextBox ID="txtq" TextMode="MultiLine" runat ="server" Height="214px" Width="600px" />
</p>
</div>
<asp:Button ID="Submit" runat="server" Text="Add a Reply to this Question"
Width="194px" OnClick="Addreply"/>
<asp:Button ID="bntanswer" runat="server" Text="View Answers" Width="148px" OnClick="viewanswer" />
</form>
</body>
</html>

<script runat="server">

Dim cn As OleDb.OleDbConnection

Dim ds As New DataSet

Dim ad As OleDb.OleDbDataAdapter

Sub Page_Load

If Not Page.IsPostBack Then

show()

End If

End Sub

Sub show(ByVal sender As Object, ByVal e As System.EventArgs)

cn = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & MapPath("dbthreads.accdb"))

cn.Open()

ad = New OleDb.OleDbDataAdapter("Select * From tblthread Where threadid=" & CInt(Request.QueryString("threadid")), cn)

ad.Fill(ds, "tblthread")

txtq.Text = ds.Tables(0).Rows(0)(4).ToString()

cn.Close()

End Sub

Sub Addreply(ByVal sender As Object, ByVal e As System.EventArgs)

Response.Redirect("Reply.aspx?threadid=" & Request.QueryString("threadid"))

End Sub

Sub viewanswer()

Response.Redirect("Answers.aspx?threadid=" & Request.QueryString("threadid"))

End Sub

</script>

 




couldn't connect to server