A full-featured column management program-> This is the second application of asp.net (iii)

Source: Internet
Author: User
A full-featured column management program-> This is the second application of asp.net (iii)
/*
Tofu production, are fine
Http://www.asp888.net Tofu Technology Station
If reproduced, please retain the full copyright information
*/
Now let's take a look at how we can save data entered in add.aspx in SQL Server
<!--#include file= "func.aspx"-->
<%
Dim conn As SqlConnection
Dim sqlread As SqlDataReader
Dim sqlCmd As SQLCommand
' So we managed and invoked many common programs, such as the connection code and so on, through the use of func.aspx files.
Conn=getconn ()
Dim strUserName As String
Dim Strpass As String
Dim strSQL As String
Strusername=request.form ("Txtuserid")
Strpass=request.form ("Txtpass")
Strsql= "Select UserPassword from Lanmuuser where Username= '" & Replacesql (strUserName) & "'"

Sqlcmd=new SQLCommand (Strsql,conn)
SqlCmd.ActiveConnection.Open ()
Sqlcmd.execute (Sqlread)
SqlCmd.ActiveConnection.Close ()
' This section is about restricting and managing users who add articles
' In the demo version, this code is shielded if we need to restrict the user
' Simply make a lanmuuser table.
If not sqlread.read () then
Response. Write ("This user does not exist")
Response.End
End If
If Sqlread (0) <>strpass Then
' The password is not correct
Response. Write ("Incorrect password")
Response.End
End If
' Verify Legal
Dim Strclassid As String
Strclassid=request.form ("Selclass")
Dim strtitle As String
Strtitle=request.form ("Txttitle")
Dim strcontent As String
Strcontent=request.form ("Txtcontent")
Dim Strselfrom As String
Strselfrom=request.form ("Selfrom")
Strsql= "INSERT into LANMU (Classid,title,content,dtime,userid,isuse,viewnum,selfrom) VALUES ("
Strsql=strsql & "" & Strclassid & "," & Replacesql (strtitle) & "," "& Replacesql (strcontent) &am P "',"
Strsql=strsql & "getdate ()," & Replacesql (strUserName) & "', ' 0 ', 0, '" & Strselfrom & "")

Sqlcmd=new SQLCommand (Strsql,conn)
SqlCmd.ActiveConnection.Open ()
' Response.Write (strSQL)
Sqlcmd.execute
Response.Write ("Congratulations, congratulations, your article has been successfully added to the article database, the administrator will check your article in the next update, if there is no problem, your article will soon appear in our columns")
Response.End
%>

Oh, is not very simple? : Don't be happy too early, this just put the data into the database, we will be in the following article, see how we show the data, after all, this talent is the main:

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.