<!--metadata type="typelib" file="c:\program files\common files\system\ado\msado15.dll"-->
<%  On Error Resume Next
'出错标志
sign=0
c_no=Trim(Request.Form("c_no"))
c_name=Trim(Request.Form("c_name"))
op=Trim(Request.Form("opt"))
If c_no="" or c_name="" or op="" then 
   Response.Redirect "xbinput.htm"
End If
Set conn = Server.CreateObject("ADODB.Connection")
strProvider = "Provider=SQLNCLI;Data Source=localhost;Initial Catalog=person; User ID=sa; Password=123; "
conn.Open strProvider
Set rs = Server.CreateObject("ADODB.RecordSet")
sql="select * from t_department"
rs.Open sql,conn,adOpenKeySet,adLockOptimistic,adcmdtext
Select Case op
   case "1"
        rs.addnew
        rs("number")=c_no
        rs("d_name")=c_name
    Case "2" 
        rs.Find "number='" & c_no & "'"
        If not rs.EOF Then
           rs("d_name")=c_name
        Else
           Response.Write "抱歉，数据库中没有欲修改的记录<BR>" 
           sign=1
        End If
   Case "3"
        rs.Find "number='" & c_no & "'"   
        If not rs.EOF Then
           rs.Delete
        Else
           Response.Write "抱歉，数据库中没有欲删除的记录<BR>" 
           sign=1
        End If     
End Select  
'执行更新操作
rs.Update
Set Errs = rs.ActiveConnection.Errors
If errs.count=0 and sign=0 then
   Response.Write "操作成功!<BR>"
Else
   Response.Write "操作失败!<BR>"
End If
rs.Close
Set conn = nothing 
%>

