<HTML> <HTML>
 <HEAD><TITLE>窗体与元素</TITLE></HEAD>
 <SCRIPT LANGUAGE="VBScript">
 <!--
 Option Explicit Dim pAdoCn
 Dim adoRst Sub cmdConnect_OnClick
 Dim strCon
     strCon=""Driver="{SQL SERVER};Server=SERVER;Uid=SA;Pwd=;Database=SONG"
     Set pAdocn=CreateObject("ADODB.Connection")
     pAdoCn.CursorLocation=3
     pAdocn.Open strCon
 End Sub Sub cmdShow_OnClick()
 Dim thisForm
     Set thisForm=Document.frmForm
     adoRst=CreateObject("ADODB.Recordset")
     Set adoRst=pAdocn.Execute("Select * From song Where [name] like ""%梦%""")
     if adoRst.Eof then Exit Sub
     adoRst.MoveLast
     adoRst.MoveFirst
     MsgBox adoRst.RecordCount
     thisForm.T1.Value=adoRst.Fields(0).Value
     thisForm.T2.Value=adoRst.Fields(1).Value
     thisForm.T3.Value=adoRst.Fields(2).Value
     thisForm.T4.Value=adoRst.Fields(3).Value
 End Sub Sub cmdPre_OnClick()
 Dim thisForm
     If adoRst Is Nothing Then Exit Sub
     If adoRst.Bof Then Exit Sub
     adoRst.MovePrevious
     If adoRst.Bof Then Exit Sub
     Set thisForm=Document.frmForm
     thisForm.T1.Value=adoRst.Fields(0).Value
     thisForm.T2.Value=adoRst.Fields(1).Value
     thisForm.T3.Value=adoRst.Fields(2).Value
     thisForm.T4.Value=adoRst.Fields(3).Value
 End Sub Sub cmdNext_OnClick()
 Dim thisForm
     If adoRst Is Nothing Then Exit Sub
     If adoRst.Eof Then Exit Sub
     adoRst.MoveNext
     If adoRst.Eof Then Exit Sub
     Set thisForm=Document.frmForm
     thisForm.T1.Value=adoRst.Fields(0).Value
     thisForm.T2.Value=adoRst.Fields(1).Value
     thisForm.T3.Value=adoRst.Fields(2).Value
     thisForm.T4.Value=adoRst.Fields(3).Value
 End Sub Sub cmdGetCount_OnClick()
 Dim thisForm
 Dim tmpRst
     Set thisForm=Document.frmForm
     tmpRst=CreateObject("ADODB.Recordset")
     Set tmpRst=pAdocn.Execute("Select Count(*) as F_A From song Where [name] like ""%刘%""")
     MsgBox tmpRst.Fields(0).Value
     tmpRst.Close()
     Set tmpRst=Nothing
 End Sub Sub Form_UnLoad()
     adoRst.Close
     Set adoRst=Nothing
     pAdocn.Close
     Set pAdocn = Nothing
 End Sub
 -->
 </SCRIPT>
 <BODY>
 <CENTER>
 <FORM NAME="frmForm">
 <Input Type = "Text" Name="T1"><p>
 <Input Type = "Text" Name="T2"><p>
 <Input Type = "Text" Name="T3"><p>
 <Input Type = "Text" Name="T4"><p>
 <Input Type = "Button" NAME="cmdConnect" VALUE="连接数据库"><p>
 <Input Type = "Button" Name="cmdShow" VALUE="显示"><p>
 <Input Type = "Button" NAME="cmdPre" VALUE="上一条"><p>
 <Input Type = "Button" Name="cmdNext" VALUE="下一条"><p>
 <Input Type = "Button" Name="cmdGetCount" VALUE="记录数"><p>
 </FORM>
 </CENTER>
 </BODY>
 </HTML>