Database Tutorial Connection Program
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
& Nbsp;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/>