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 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?