Option Explicit
Dim rst As New ADODB.Recordset 这里提示出错,我让别人看了一下,说是"可能是你没有引入asp.dll "怎么导入麻烦高手指点
Private Sub Preview1_OnClose()
End Sub
Private Sub Command1_Click()
Dim ssql As String
ssql = "delete from student where sno='" & Text1.Text & " ' "
Set rst = Nothing
rst.open ssql, cn, adOpenKeyset, adLockOptimistic
End Sub
Private Sub Command2_Click()
Dim ssql As String
ssql = "select * from student order by sno"
Set rst = New ADODB.Recordset
rst.open ssql, cn, adOpenKeyset, adLockPessimistic
Set DataGrid1.DataSource = rst
'DataGrid1.Refresh
Text1.Text = rst.Fields("sno")
Text2.Text = rst.Fields("sname")
Text3.Text = rst.Fields("Sage")
Text4.Text = rst.Fields("ssex")
End Sub
Private Sub Command3_Click()
If Not rst.EOF Then
rst.MoveNext
End If
If rst.EOF Then
rst.MoveFirst
End If
Text1.Text = rst.Fields("sno")
Text2.Text = rst.Fields("sname")
Text3.Text = rst.Fields("Sage")
Text4.Text = rst.Fields("ssex")
Text5.Text = rst.Fields("sdept")
End Sub
Private Sub Command4_Click()
If Not rst.BOF Then
rst.MovePrevious
End If
If rst.BOF Then
rst.MoveLast
End If
Text1.Text = rst.Fields("sno")
Text2.Text = rst.Fields("sname")
Text3.Text = rst.Fields("Sage")
Text4.Text = rst.Fields("ssex")
End Sub
Private Sub Command7_Click()
Dim ssql As String
ssql = "insert into student(sno,sname,sage,ssex,sdept) values(" & Text1.Text & " ,'" & Text2.Text & " '," & Text3.Text & ",'" & Text4.Text & " ',' " & Text5.Text & " ')"
Set rst = Nothing
rst.open ssql, cn, adOpenKeyset, adLockOptimistic
End Sub
Private Sub Data1_Validate(Action As Integer, Save As Integer)
End Sub
Private Sub Command8_Click()
Dim ssql As String
ssql = " update student set sname='" & Text2.Text & "' where sno=" & Text1.Text & " "
Set rst = Nothing
rst.open ssql, cn, adOpenKeyset, adLockOptimistic
End Sub
Private Sub Form_Load()
Dim strpath As String
Set cn = New ADODB.Connection
'cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Persist Security Info=True;Data Source=" & strpath & "\05数据库石文文.mdb"
'cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Password="""";Persist Security Info=True;Data Source=" & strpath & "\05数据库石文文.mdb"
'cnProvider=MSDASQL.1;Persist Security Info=False;Data Source=05数据库石文文
cn.open
End Sub