求救!!!当前记录集不能更新
mmxqf 2007-01-06 05:04:44 程序如下:
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\成绩管理.mdb;Persist Security Info=False"
con.CursorLocation = adUseClient
con.Open
sql = "select 学号,姓名,课程名称,平时表现,期中成绩,期末成绩,总评 from 成绩表"
Set myRs = con.Execute(sql)
'myRs.Open sql, con, adOpenKeyset, adLockOptimistic
If Check = False Then
Exit Sub
End If
With myRs
myRs.Fields(0).Value = txtNo.Text--------程序运行到这里就说:当前记录集不支持更新,这可能是提供程序的限制,也可能是选定锁定类型的限制
myRs.Fields(1).Value = txtName.Text
myRs.Fields(2).Value = txtCourse.Text
myRs.Fields(3).Value = txtpsbx.Text
myRs.Fields(4).Value = txtqzcj.Text
myRs.Fields(5).Value = txtqmcj.Text
myRs.Fields(6).Value = txtzp.Text
'判断楼号是否存在
If Modify = False Then
If myRs.Fields(0) = True Then
MsgBox "学号已经存在,请重新输入"
txtNo.SetFocus
txtNo.SelStart = 0
txtNo.SelLength = Len(txtNo)
Exit Sub
End If
End If
If Modify = False Then
sql = "INSERT INTO 成绩表(学号,姓名, 课程名称,平时表现,期中成绩,期末成绩" _
+ " 总评)" + " VALUES('" + Trim(学号) + "'," + Trim((姓名)) _
+ "," + Trim((课程名称)) + "," + Trim((平时表现)) + "," + Trim(期中成绩) + "," + Trim(期末成绩) + "," + Trim(总评) + "')"
' myRs.Open sql, con
MsgBox "添加成功"
Else
sql = "UPDATE 成绩表 SET 姓名='" + Trim(姓名) _
+ "', 课程名称=" + Trim(课程名称) + ",平时表现=" _
+ Trim(平时表现) + ",期中成绩='" + Trim(期中成绩) + ",期末成绩='" + Trim(期末成绩) + ",总评='" + Trim(总评) _
+ "' WHERE BuildingNo='" + Trim(TmpNo) + "'"
'myRs.Open sql, con
MsgBox "修改成功"
End If
End With
Unload Me