asp+ version of the simple message board production (ii)

Source: Internet
Author: User
Tags config version
asp+ version of the simple message board production (ii)
/*
Tofu production, are fine
Http://www.asp888.net Tofu Technology Station
If reproduced, please retain the copyright information
*/

In the message input interface completed, naturally to be ready to do the input of the message content. One of the key points here is how to read the contents of our config.web, and I use the following statements
Dim CFG as HashTable
CFG = Context.getconfig ("appsettings")
Conn = New SqlConnection (cfg ("Conn"))
So we get the connection string we set up in Config.web, and the program is as follows
<%@ 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") ' User IP address
Strsql= "INSERT into Msgboard (nickname,email,ipaddr,msgtime,msgtitle,msgcontent) VALUES ("
Strsql=strsql & "' & Strnickname & ', '" & Stremail & "', '" & Stripaddr & ", GETDATE (), '" &am P 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>
We actually see, we know that this procedure and the ASP program is no different, by the way, the only benefit of following MS is that they are always very compatible with their previous systems when they upgrade, except that because of the reference to the Ado.net, the operation of the database has changed a lot. The other code basically does not have any big change, the bad said here said the wrong word, is not no big change, changes still is very big, only to formerly compatible, we such simple application, does not seem to involve any complex change:)


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.