问题描述
- 用ADO控件编的一个简易学生成绩管理器,运行时显示找不到可安装的ISAM,求解决
-
Private Sub Command1_Click()
On Err GoTo MyErr
If Command1.Caption = "添加" Then
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label1(6).Caption = ""
Command1.Caption = "保存"
Else
If ChkData Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("num") = Trim(Text1.Text)
Adodc1.Recordset.Fields("name") = Trim(Text2.Text)
Adodc1.Recordset.Fields("Lang") = Trim(Text3.Text)
Adodc1.Recordset.Fields("Math") = Trim(Text4.Text)
Adodc1.Recordset.Fields("Eng") = Trim(Text5.Text)
Adodc1.Recordset.Fields("scor") = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text)
Adodc1.Recordset.Update
MsgBox "添加学生成绩信息成功!", vbOKOnly, "系统提示"
Command1.Caption = "添加"
End If
Exit Sub
MyErr:
MsgBox "添加学生成绩信息失败!", vbOKOnly, "系统提示"
End SubPrivate Sub Command2_Click()
On Err GoTo MyErr
If ChkData Then
Adodc1.Recordset("num") = Trim(Text1.Text)
Adodc1.Recordset("name") = Trim(Text2.Text)
Adodc1.Recordset("Lang") = Trim(Text3.Text)
Adodc1.Recordset("Math") = Trim(Text4.Text)
Adodc1.Recordset("Eng") = Trim(Text5.Text)
Adodc1.Recordset("scor") = Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text)
Adodc1.Recordset.Update
MsgBox "修改学生成绩信息成功!", vbOKOnly, "系统提示"
End If
Exit Sub
MyErr:
MsgBox "修改学生成绩信息失败!", vbOKOnly, "系统提示"
End SubPrivate Sub Command3_Click()
On Err GoTo MyErr
Adodc1.Recordset.Delete
MsgBox "删除记录成功!", vbOKOnly, "系统提示"
Exit Sub
MyErr:
MsgBox "删除记录失败,请重试!", vbOKOnly, "系统提示"
End SubPrivate Sub Command4_Click()
End
End SubPrivate Sub Form_Load()
Adodc1.Visible = False
lst.ColumnHeaders.Add , , "学号"
lst.ColumnHeaders.Add , , "姓名", , 2
lst.ColumnHeaders.Add , , "语文", , 2
lst.ColumnHeaders.Add , , "数学", , 2
lst.ColumnHeaders.Add , , "英语", , 2
lst.ColumnHeaders.Add , , "总成绩", , 2
lst.FullRowSelect = True
lst.GridLines = True
lst.LabelEdit = lvwManual
lst.View = lvwReport
Dim Li_RecCount As Integer
Dim Li_i As Integer
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "Data.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from 成绩表"
Adodc1.Refresh
Li_RecCount = Adodc1.Recordset.RecordCount - 1
For Li_i = 0 To Li_RecCount
lst.ListItems.Add , , Adodc1.Recordset.Fields("num").Value
lst.ListItems.Item(Li_i + 1).SubItems(1) = Adodc1.Recordset.Fields("name").Value
lst.ListItems.Item(Li_i + 1).SubItems(2) = Adodc1.Recordset.Fields("lang").Value
lst.ListItems.Item(Li_i + 1).SubItems(3) = Adodc1.Recordset.Fields("math").Value
lst.ListItems.Item(Li_i + 1).SubItems(4) = Adodc1.Recordset.Fields("Eng").Value
lst.ListItems.Item(Li_i + 1).SubItems(5) = Adodc1.Recordset.Fields("scor").Value
Adodc1.Recordset.MoveNext
Next
Adodc1.Recordset.MoveFirst
End SubPrivate Sub lst_ItemClick(ByVal Item As MSComctlLib.ListItem)
Text1.Text = lst.SelectedItem.Text
Text2.Text = lst.SelectedItem.SubItems(1)
Text3.Text = lst.SelectedItem.SubItems(2)
Text4.Text = lst.SelectedItem.SubItems(3)
Text5.Text = lst.SelectedItem.SubItems(4)
Label1(6).Caption = lst.SelectedItem.SubItems(4)
End Sub
解决方案
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "Data.mdb;Persist Security Info=False"
找不到可安装的ISAM,系统没有相应的ado驱动。要么换连接方式,要么装完整版的操作系统。
解决方案二:
http://support.microsoft.com/kb/318161