JossinC 2016-07-18 12:26 采纳率: 0%
浏览 2629

缺少更新或刷新的键列信息

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

Private Sub Command3_Click()
DataGrid1.Visible = False
DataGrid2.Visible = False

End Sub

Private Sub Command4_Click()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim str As String
conn.Open "provider=Microsoft.jet.oledb.4.0;data source=" & App.Path & "\trainTime.mdb;persist security info = false"
sql = "select Train.tno as 车次号,Dtime as 出发日期,Ccondition as 有无空调,Fsta as 起始站,Lsta as 终点站,Ftime as 出发时间,Ltime as 到达时间,LastTicket as 剩余票数,Price as 价格 from [Train],[Ticket] where Train.tno= Ticket.tno and Fsta like'%" & Text2.Text & "%' and Lsta like '%" & Text3.Text & "%' and Train.tno like '%" & Text1.Text & "%' and Ttype is not null and Ctype is not null and Ccondition is not null and Fsta is not null and Lsta is not null and Ftime is not null and Ltime is not null and Price is not null and Dtime = #" & Calendar1.Value & "#"
rs.CursorLocation = adUseClient
rs.Open sql, conn, 3, 3
Set DataGrid2.DataSource = rs
DataGrid2.Refresh
DataGrid2.Visible = True

End Sub

Private Sub Form_Load()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.Open "provider=Microsoft.jet.oledb.4.0;data source=" & App.Path & "\trainTime.mdb;persist security info = false"
Dim dd As Date
dd = Date
sql = "select*from [Ticket] where Dtime <#" & dd & "#"

rs.Open sql, conn, 1, 2
If rs.RecordCount = 0 Then
rs.Close
GoTo m

Else
rs.Close
sql = "select* from [Ticket]"
rs.Open sql, conn, 1, 2
rs.MoveLast
While Not rs.BOF
rs!Dtime = rs!Dtime + 1
rs.MovePrevious
Wend
End If
rs.Close
sql = "select*from [Purchase] where Dtime<#" & dd & "#"
rs.Open sql, conn, 1, 2
If rs.RecordCount = 0 Then
rs.Close
GoTo m
Else
rs.Delete
rs.Update
End If
m:

End Sub
运行起来出现了上述缺少更新或刷新的键列信息,主键没有问题,请问大神们怎么修改?

  • 写回答

2条回答 默认 最新

  • Robot-C 2016-07-18 12:32
    关注

    今天碰到一个很奇怪的问题,更新一个视图时,老是出现一个“缺少更新或刷新的键列信息”的错误,但是我只是更新了主表的一个字段,关联表我又没有修改。查了好久,后天发现居然是一个多了一个distinct关键字。原查询语名如下:select distinct a.*,b.f_date as fdate from T_y_zxks_yjsbm a left join T_Y_yjsbm_fee b on ......
    答案就在这里:缺少更新或刷新的键列信息
    ----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料