文本框中输入的是学号,查询的还是学号,这样可以吗?
文本框中输入的是学号,查询的还是学号,这样可以吗?
能帮我看看吗?点击确定之后就没什么反映了 Private Sub Command2_Click() Dim sql3 As String Dim sql4 As String Dim sql5 As String Dim sql6 As String Dim str As String Dim Today2 As Date
Set conn = New ADODB.Connection Set rs = New ADODB.Recordset conn.ConnectionString = "Driver={sql server};server=LIUMIAO;uid=sa;pwd=;database=vbsql" conn.ConnectionTimeout = 30 conn.Open str = "select sno from stutakedown where sno='" & Trim(Text1.Text) & "' " Set rs = conn.Execute(str) '前面是已经刷过卡了,表stutakedown中已经有记录了,这是第二次刷卡(在另一个文本框中输入同样的学号),查找该用户 If rs.EOF = False Then Today2 = Now sql3 = "update stutakedown set endtime= Today2 where sno='" & Trim(Text2.Text) & "'" conn.Execute (sql3) '更新结束的时间(还可以用 insert) moneys1 = moneys - (Today2 - Today1) * 0.017 '计算费用
sql4 = "update newcard set moneys=moneys1 where sno='" & Text2.Text & "'" conn.Execute (sql4) '更新表中的金额 '以下是再显示一下用户的信息 sql6 = "select sname,moneys,sno from newcard where sno='" & Trim(Text2.Text) & "'" Set rs = conn.Execute(sql6)
sname = rs.Fields.Item(0) moneys = rs.Fields.Item(1) sno = rs.Fields.Item(3) xianshi.Label1.Caption = rs.Fields.Item("sname") xianshi.Label2.Caption = rs.Fields.Item("moneys") xianshi.Show End If End Sub