Sub Opensql ()
Set Sqlrs=server. CreateObject ("Adodb.recordset")
Set Sqlcn=server.createobject ("Adodb.connection")
Sqlconstr= "Driver={sql server};server=xiewen;uid=sa;pwd=123456;database=jimmy"
Sqlcn.open Sqlconstr
End Sub
Feature handler ASP tutorial save content to Database
<%dim F_id,tag,names,lytxt
F_id=request. QueryString ("id")
Tag=request. QueryString ("tag")
Lytxt=html_encode (Request. Form ("Lytxt"))
Names=session ("Lyname")
If names= "" Then
names= "Anonymous"
End If
if (not IsNumeric (f_id)) or (not IsNumeric (tag)) or Len (lytxt) <5 Then
Response. Write (' <script language= ' javascript tutorial ' >alert (' article content cannot be less than five characters! '); History.back ();</script> ")
Else
Sql= "SELECT * FROM Guestbook"
On Error Resume Next
Call Opensql ()
Sqlrs.open sql,sqlcn,1,3
Sqlrs.addnew
Sqlrs ("ly") =lytxt
Sqlrs ("f_id") =f_id
Sqlrs ("tag") =tag
Sqlrs ("name") =names
Sqlrs.update
If Err=0 Then
Response. Redirect ("list.asp?id=" &f_id& "&tag=" &tag)
Else
Response. Write ("<script language= ' JavaScript" >alert (' very sorry, your message failed! '); History.back ();</script> ")
End If
End If
%>
HTML Provision page
<input name=lytxt >
<input Type=submit Value submitted/>
Original reprint of this site annotated www.111cn.net