Click here to Skip to main content
15,897,519 members
Articles / Web Development / ASP.NET

ASP.NET Guestbook using MS Access

Rate me:
Please Sign up or sign in to vote.
3.32/5 (19 votes)
16 Mar 20042 min read 647.2K   6.1K   53  
Shows an easy way of building a guestbook using ADO.NET and Access
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDB" %>

<html>
	<head>
		<title>My ASP.NET Guestbook</title>
		<script runat="server">
sub OnBtnSendClicked (s As Object, e As EventArgs)
	Dim strConn as string = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("guestbook.mdb") & ";"
	
	Dim MySQL as string = "INSERT INTO Guestbook (Name, EMail, URL, Comment) VALUES ('" & txtName.Text & "','" & txtEMail.Text & "','" & txtURL.Text & "','" & txtComment.Text & "')"
	Dim MyConn as New OleDBConnection (strConn)
	Dim cmd as New OleDBCommand (MySQL, MyConn)
	MyConn.Open ()
	cmd.ExecuteNonQuery ()
	MyConn.Close ()
	
	Response.Redirect ("guestlog.aspx")
end sub

sub OnBtnClearClicked (s As Object, e As EventArgs)
	txtName.Text = ""
	txtEMail.Text = "yourname@somebody.com"
	txtURL.Text = "http://"
	txtComment.Text = ""
end sub
</script>

        <style type="text/css">
BODY {
		scrollbar-3dlight-color:black;
		scrollbar-arrow-color:white;
		scrollbar-base-color:RGB(75,75,150);
		scrollbar-track-color:white;
		scrollbar-darkshadow-color:white;
		scrollbar-face-color:RGB(75,75,150);
		scrollbar-highlight-color:RGB(75,75,150);
		scrollbar-shadow-color:black	}
</style>

</head>
	<body ms_positioning="GridLayout">
		<form id="Form1" method="post" runat="server">
			<asp:label id="Label5" runat="server" font-names="Tahoma" font-size="X-Large" style="LEFT: 54px; POSITION: absolute; TOP: 24px">My ASP.NET Guestbook</asp:label>
			<asp:textbox id="txtName" runat="server" font-size="X-Small" font-names="Tahoma" width="174px" height="24px" tabindex="1" style="LEFT: 136px; POSITION: absolute; TOP: 114px"></asp:textbox>
			<asp:label id="Label1" runat="server" font-names="Tahoma" font-size="X-Small" style="LEFT: 54px; POSITION: absolute; TOP: 119px">Name:</asp:label>
			<asp:textbox id="txtEMail" runat="server" font-size="X-Small" font-names="Tahoma" width="174" height="24" tabindex="2" style="LEFT: 134px; POSITION: absolute; TOP: 155px">yourname@somebody.com</asp:textbox>
			<asp:label id="Label2" runat="server" font-size="X-Small" font-names="Tahoma" style="LEFT: 54px; POSITION: absolute; TOP: 159px">E-mail:</asp:label>
			<asp:textbox id="txtURL" runat="server" font-names="Tahoma" font-size="X-Small" width="174px" height="24px" tabindex="3" style="LEFT: 135px; POSITION: absolute; TOP: 194px">http://</asp:textbox>
			<asp:label id="Label3" runat="server" font-size="X-Small" font-names="Tahoma" style="LEFT: 54px; POSITION: absolute; TOP: 199px">Webpage:</asp:label>
			<asp:label id="Label4" runat="server" font-size="X-Small" font-names="Tahoma" style="LEFT: 55px; POSITION: absolute; TOP: 234px">Comment:</asp:label>
			<asp:textbox id="txtComment" runat="server" font-names="Tahoma" width="179px" height="81px" textmode="MultiLine" tabindex="4" style="LEFT: 134px; POSITION: absolute; TOP: 234px" maxlength="250"></asp:textbox>
			<asp:button id="btnSend" onclick="OnBtnSendClicked" runat="server" font-names="Tahoma" text="Send" backcolor="Navy" tabindex="5" font-size="X-Small" forecolor="White" style="LEFT: 212px; POSITION: absolute; TOP: 328px"></asp:button>
			<asp:button id="btnClear" onclick="OnBtnClearClicked" runat="server" text="Clear" backcolor="Navy" tabindex="6" font-names="Tahoma" font-size="X-Small" forecolor="White" style="LEFT: 267px; POSITION: absolute; TOP: 328px"></asp:button>
		</form>
	</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here



Comments and Discussions