缺少更新键列信息
Private Sub Command2_Click()DataGrid2.Visible = False
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim r As New ADODB.Recordset
conn.Open "provider=Microsoft.jet.oledb.4.0;data source=" & App.Path & "\trainTime.mdb;persist security info = false"
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Calendar1.Value = "" Then
MsgBox "请输入完整的信息"
GoTo m
Else
sq = "select * from [Ticket],[Train] where Ticket.tno = Train.tno and Ticket.tno = '" & Text1.Text & "' and Fsta = '" & Text2.Text & "' and Lsta = '" & Text3.Text & "' and Dtime= #" & Calendar1.Value & "#"
rs.Open sq, conn, 1, 2
If rs.RecordCount = 0 Then
MsgBox " 无此车票"
GoTo m
rs.Close
Else
rs.Close
sql = "select Train.tno as 车次号,Dtime as 出发日期,Cnum as 座位数量,LastTicket as 剩余票数 from [Ticket],[Train] where Ticket.tno = Train.tno and Ticket.tno = '" & Text1.Text & "' and Fsta = '" & Text2.Text & "' and Lsta = '" & Text3.Text & "' and Dtime= #" & Calendar1.Value & "#"
rs.CursorLocation = adUseClient
rs.Open sql, conn, 1, 2
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
DataGrid1.Visible = True
a = MsgBox("确定购买?", 35, "确认")
If a = vbYes Then
If rs!剩余票数 < 1 Then
MsgBox "此票已售完"
Else
sql = "select * from purchase"
r.Open sql, conn, 1, 2
r.AddNew
r!tno = rs!车次号
r!Dtime = rs!出发日期
rs!剩余票数 = rs!剩余票数 - 1
r!Seat = rs!座位数量 - rs!剩余票数
rs.Update
r.Update
End If
End If
End If
End If
m:
End Sub
运行起来出现了上述缺少更新或刷新的键列信息,主键没有问题,请问大神们怎么修改?
[此贴子已经被作者于2016-7-18 20:33编辑过]