sql="update 表 set 缺勤人数=缺勤人数+1 where id=1" conn.execute(sql)
程序如下:Private Sub Cmd_absent_Click() Dim SQL As String If txtNo = "" Then MsgBox "请选择学号!", vbExclamation, "提示" Else Set MyRs = New ADODB.Recordset SQL = "update 考勤表 set 旷课人数=旷课人数+1 where 学号='" + Trim(txtNo.Text) + "' and 班级名称='" + Trim(Combo1.Text) + "'and 课程名称='" + Trim_(DataCombo1.BoundText) + "'" MyRs.Open SQL, Conn, adOpenKeyset, adLockOptimistic--------运行到这里就说至少一个参数未被指定值 If MyRs.EOF Then MyRs.AddNew End If With MyRs MyRs.Fields(0) = txtNo.Text MyRs.Fields(1) = Combo1.Text MyRs.Fields(2) = DataCombo1.BoundText Set DataGrid1.DataSource = MyRs MyRs.Update End With MyRs.Close End If End Sub
conn.execute(sql)
Dim SQL As String
If txtNo = "" Then
MsgBox "请选择学号!", vbExclamation, "提示"
Else
Set MyRs = New ADODB.Recordset
SQL = "update 考勤表 set 旷课人数=旷课人数+1 where 学号='" + Trim(txtNo.Text) + "' and 班级名称='" + Trim(Combo1.Text) + "'and 课程名称='" + Trim_(DataCombo1.BoundText) + "'" MyRs.Open SQL, Conn, adOpenKeyset, adLockOptimistic--------运行到这里就说至少一个参数未被指定值 If MyRs.EOF Then
MyRs.AddNew
End If
With MyRs
MyRs.Fields(0) = txtNo.Text
MyRs.Fields(1) = Combo1.Text
MyRs.Fields(2) = DataCombo1.BoundText
Set DataGrid1.DataSource = MyRs
MyRs.Update
End With
MyRs.Close
End If
End Sub