Lotus Notes 利用Ado防问Access 数据库 .

Sub Initialize
Dim oConn As Variant
Dim oRs As Variant
Dim filePath As String
Dim Index As Integer
Dim vValue As Variant
Dim strName As String
Dim strValue As String
Dim docNew As NotesDocument
Dim count As Long
Dim session As New notessession
Dim db As notesdatabase
Set db=session.currentdatabase

getAccessDBData = True
' Map contact database to physical path
strFileName = "C:/MaBase1.mdb"
'If FileExist( strFileName ) Then
db.DelayUpdates = True
' Create ADO Connection Component to connect with database
Set oConn = CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileName
' Execute a SQL query and store the results within recordset
Set oRs = oConn.Execute("SELECT FirstName,LastName,Company From Contacts")

Do While (Not oRs.eof)
Set docNew = New NotesDocument( db )
count = count + 1

docNew.Form = "Person"
For Index = 0 To (oRs.fields.count-1)
strName = oRs(Index).Name
vValue = oRs(Index).Value
If Isnull(vValue) Then
strValue = ""
Else
strValue = Cstr(vValue)
End If
Call docNew.ReplaceItemValue(strName, strValue)
Next
Call docNew.ComputeWithForm(True,False)
Call docNew.Save(True, False)
If Not session.IsOnServer Then
If (count Mod 100) = 0 Then Print Str(count) & " person documents imported."
End If
oRs.MoveNext
Loop


oRs.Close
oConn.Close
Print Str(count) & " person documents imported."
getAccessDBData = False
Print "File not Found -> " & strFileName
End Sub

转载于:https://www.cnblogs.com/hannover/archive/2011/11/03/2235100.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值