本文共 1786 字,大约阅读时间需要 5 分钟。
在做上下机的时候,发现了一个很大的问题,那就是上机信息可以记录,下机的信息没有反应到数据库里面。
txtsqlline = "select * from line_info where cardno='" & txtCardNo.Text & "' and Ondate='" & Trim(txtondate.Text) & "' and ontime='" & Trim(txtontime.Text) & "'" ' txtSQL = "select * from student_Info Where cardno='" & Trim(txtCardNo.Text) & "'and status='使用'"'and status='正在上机'" Set mrcLine = ExecuteSQL(txtsqlline, MsgText)
答案:不一定,因为这个要看你的具体代码。
就我而言,这种方法不太好,因为VB执行语句过程中有时间问题,他不可能通过一个时间点把整个语句执行,他只会一条一条的执行。所以一定会有时间延误。'txtSQL = "select * from Line_Info where status=' 正常上机' and cardno = '" & Trim(txtCID.Text) & "'" '卡号状态是正常上机的,且等于text框的卡号可以下机。 txtsqlline = "select * from Line_Info where status='正在上机' and cardno = '" & Trim(txtCardNo.Text) & "'" '卡号状态是正常上机的,且等于text框的卡号可以下机。 ' txtsqlline = "select * from line_info where cardno='" & txtCardNo.Text & "' and Ondate='" & Trim(txtondate.Text) & "' and ontime='" & Trim(txtontime.Text) & "'" ' txtSQL = "select * from student_Info Where cardno='" & Trim(txtCardNo.Text) & "'and status='使用'"'and status='正在上机'" Set mrcLine = ExecuteSQL(txtsqlline, MsgText)' mrcLine.AddNew txtclosedate.Text = Format(Date, "yyyy-mm-dd") txtclosetime.Text = Format(Time, "hh:mm") mrcLine.Fields(8) = Trim(txtclosedate.Text) 'txtclosedate mrcLine.Fields(9) = Trim(txtclosetime.Text) 'txtclosetime mrcLine.Fields(10) = Trim(txtconsumeTime.Text) mrcLine.Fields(11) = Val(Trim(txtconsumeMoney.Text)) mrcLine.Fields(12) = Val(Trim(txtCardNo.Text)) mrcLine.Fields(13) = "正常下机" mrcLine.Fields(14) = Trim(VBA.Environ("computername")) mrcLine.Update mrcLine.Close
所以,一定要想想主键的问题。
转载地址:http://kxhe.baihongyu.com/