当前位置: 代码迷 >> Lotus >> 哪位高手有bs下,使用ado把notes数据通过代理导入到sql中的代码
  详细解决方案

哪位高手有bs下,使用ado把notes数据通过代理导入到sql中的代码

热度:118   发布时间:2016-05-05 07:18:58.0
谁有bs下,使用ado把notes数据通过代理导入到sql中的代码?
如题:
问:用定时代理使用ado把notes数据通过代理导入到sql中的效率如何,与ls,还有java代码比较如何?

------解决方案--------------------
能用ADO当然用ADO最好了,.net这些不都是用的ado吗,因为是直接调用windows的东西,所以效率也是比较高的,比Java高多了。不过也是有限制的,就是如果你是用在BS的话,服务器必须是windows平台的,这样才能用ADO。
示例代码如下:
VB code
m_conString = "driver={SQL Server};server="+server+";uid="+uid+";pwd="+psw+";database="+db                    Set m_con = CreateObject("ADODB.Connection")        If m_conString = "" Then             Msgbox "Please provide with the connection string!",0+16,"Lotus Notes"            Exit Sub                    End If        m_con.ConnectionString = m_conString        Call m_con.open        If m_con Is Nothing Then             Msgbox "Connection failed!",0+16,"Lotus Notes"            Exit Sub        End If        If m_con.state = 0 Then             Msgbox "Connection failed!",0+16,"Lotus Notes"            Exit Sub        End If
------解决方案--------------------
Dim vConn As Variant'数据库的adodb链接。
Dim strSql As String

Set vConn=FMJGetConn()'createobject("ADODB.CONNECTION")
'vConn.connectionString="Provider=SQLOLEDB;Data Source=21.8.143.248;Initial Catalog=Notes; User ID=Notes;Password=Notes;"'定义连接字符串
Call vConn.open
vConn.BeginTrans

Dim strUnid As String
Dim strTitle As String
Dim strDepartment As String
Dim strFlowNo As String
Dim strFileNo As String
Dim strArchiveUser As String
Dim strAuthor As String
Dim strSubmitTime As String
Dim strCreateTime As String
Dim strOthers As String
Dim strDxl As String

Set nCurUser=New NotesName(session.UserName)
Set nAuthor=New NotesName(docParent.originalAuthor(0))

strUnid=docParent.unid(0)
strTitle=docParent.title(0)
strDepartment=docParent.department(0)
strFlowNo=docParent.snFlow(0)
strFileNo=docParent.sn(0)
strArchiveUser=nCurUser.Abbreviated
strAuthor=nAuthor.Abbreviated
strSubmitTime=docParent.timesubmit(0)
strCreateTime=docParent.Created
strDxl=Replace(stream.ReadText(),"'","''")
strSql="INSERT INTO [Notes].[dbo].[archiveDoc]([unid],[title],[department],[flowNo],[fileNo],[archiveUser],[author],[submitTime],[createTime],[others],[dxl]) VALUES" &_
"('" & strUnid & "'" &_
",'" & strTitle & "'" &_
",'" & strDepartment & "'" &_
",'" & strFlowNo & "'" &_
",'" & strFileNo & "'" &_
",'" & strArchiveUser & "'" &_
",'" & strAuthor & "'" &_
",'" & strSubmitTime & "'" &_
",'" & strCreateTime & "'" &_
",'" & strOthers & "'" &_
",'" & strDxl & "')"

vConn.execute strSql
vConn.CommitTrans
Call vConn.close
Set vConn=Nothing



Function FMJGetConn() As Variant
On Error Goto e
Dim session As New NotesSession
Dim db As NotesDatabase
Dim vConn As Variant'数据库的adodb链接。
Dim doc As NotesDocument
Set vConn=createobject("ADODB.CONNECTION")
Set db=session.CurrentDatabase
Set doc=db.GetProfileDocument("profile")
vConn.connectionString=doc.connString(0)'定义连接字符串
Set FMJGetConn=vConn
Exit Function
e:
Dim fmjError As String
fmjError = "script库-common-FMJGetConn" & Erl & ":" & Error
  相关解决方案