码迷,mamicode.com
首页 > 数据库 > 详细

access的一些简单操作

时间:2014-09-02 14:03:44      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:os   io   ar   数据   2014   cti   log   sp   on   

Option Compare Database

 

Private sqladdress As String

Private PrintSavebool As Boolean

 

‘程序初始化
Private Sub Init()
sqladdress = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=U:\2.Personal\Ye\log.mdb;Persist Security Info=False"

PrintSavebool = False

 


End Sub

‘判断是是否存在在数据库中
‘2014.09.02

‘用于查看

Private Sub CheckOrder(ordernumber As String)

PrintSavebool = False

On Error GoTo ErrHandle

Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Set rs = Nothing

SQL = "select [DT] from [PrintLog] where [ORDERID]=" + "‘" + ordernumber + "‘"

conn.Open sqladdress
rs.Open SQL, conn


If Not rs.EOF Then
‘ If MsgBox("order number:" + ordernumber + "Print had Done,Time:" + CStr(rs!DT) + " continue?", vbYesNo) = vbYes Then
‘Else

‘Cancle = True

‘End If


MsgBox "order number:" + ordernumber + "Print had Done,Time:" + CStr(rs!DT) + " continue?"

PrintSavebool = False
Else

PrintSavebool = True
End If
rs.Close
Set rs = Nothing


Exit Sub


‘错误处理
ErrHandle:
MsgBox "check log database error"

Exit Sub

End Sub

 

‘把打印记录放到数据库中
‘2014.09.02

Public Sub SaveOrder(ordernumber As String)

If PrintSavebool = False Then

Exit Sub
End If


On Error GoTo ErrHandle

Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Set rs = Nothing

SQL = "insert into [PrintLog]([ORDERID],[DT]) values (" + "‘" + ordernumber + "‘" + "," + "‘" + CStr(Now) + "‘" + ")"
conn.Open sqladdress
rs.Open SQL, conn

Set rs = Nothing
Exit Sub


‘错误处理
ErrHandle:
MsgBox "record log error"
Exit Sub

End Sub

‘Private Sub Report_Page()

‘‘Call Log(Label0.Caption)
‘End Sub
‘在打印


Public Sub Log(ordernumber As String)

Call Init

Call CheckOrder(ordernumber)

Call SaveOrder(ordernumber)

 

End Sub

access的一些简单操作

标签:os   io   ar   数据   2014   cti   log   sp   on   

原文地址:http://www.cnblogs.com/shumaojie/p/3951302.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!