asp+版本簡單的留言板的製作(二)

來源:互聯網
上載者:User
asp+版本簡單的留言板的製作(二)
/*
豆腐製作,都是精品
http://www.asp888.net 豆腐技術站
如轉載,請保留著作權資訊
*/

在留言的錄入介面完成後,自然要準備做留言內容的錄入了。這個其中一個很關鍵的地方就是如何將我們在config.web 的內容讀取出來,我用了下面的幾條語句
Dim Cfg as HashTable
Cfg = Context.GetConfig("appsettings")
Conn = New SQLConnection(cfg("Conn"))
這樣就得到了我們在config.web 中設定的 串連串,程式如下
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQL" %>
<script runat="server" language="VB">
Sub Page_Load(Src As Object, E As EventArgs)

Dim conn As SQLConnection
Dim Cfg as HashTable
Cfg = Context.GetConfig("appsettings")
Conn = New SQLConnection(cfg("Conn"))
dim strSQL as string
dim strNickName as string
dim strMail as string
dim strTitle as string
dim strContent as string
dim strIPAddr as string
strNickName=replace(request.form("txtName"),"'","''")
strEmail=replace(request.form("txtMail"),"'","''")
strTitle=replace(request.form("txtTitle"),"'","''")
strContent=replace(request.form("txtContent"),"'","''")
strIPAddr=Request.ServerVariables ("REMOTE_ADDR") '使用者IP地址
strSQL="insert into msgBoard(nickname,email,ipAddr,msgTime,msgTitle,msgContent)values("
strSQL=strSQL & "'" & strNickName & "','" & strEMail & "','" & strIPAddr & "',getdate(),'" & strTitle & "','" & strContent & "')"
response.write(strSQL)
Dim Cmd As SQLCommand
Cmd = New SQLCommand(strSQL,conn)
Cmd.ActiveConnection.Open()
Cmd.Execute()
Cmd.ActiveConnection.Close()
Response.Redirect("showmsg.aspx")
end sub
</script>
大家其實一看,就知道這段程式其實和asp的程式沒有什麼區別嘛,對了,跟著MS 的唯一的好處就是 他們在升級的時候總是對他們的以前的系統進行了很好的 相容,除了因為引用了 ado.net 而使得資料庫的操作 改變的比較多以外,其他的代碼基本上都沒有什麼大的改變,糟糕 說道這裡 就說錯了一句話,不是沒有什麼大的改動,變化還是很大的,只不過對以前相容了,我們這樣的簡單的應用,似乎也不會牽扯到什麼複雜的改變的:)


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.