rbend
asked on
How do I rewite this code to connect to a Domino DECS connection vs an ADO connection?
Need help rewriting this.
I need to connect to a DECS connection already established. (same name).
-------------------------- ---------- ---------- ---------- ---------- -----
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim EODMark As String, tempPONumb As String, currPO As String, povend As String, postat As String, sql As String
Dim GetNextPO As Integer
Dim poline As Integer, cnt As Integer
Dim tdoc As NotesDocument
Dim ItemView As NotesView
Dim tempdate As Variant
Dim datediff As Double
Dim ret As Long
Dim cmd As Variant
Dim cols As Variant
Dim tval As Variant
Dim tDesc As Variant
Set db = session.CurrentDatabase
Set ItemView = db.GetView("(Items)")
' ret = Messagebox("Use ADO (Yes) or RDO (No)", 4, "Question")
' If ret = 6 Then
Set con = CreateObject("ADODB.Connec tion.2.5")
Set res = CreateObject("ADODB.Record set.2.5")
If con.State = adStateOpen Then
res.Cancel
con.Cancel
End If
con.ConnectionString = "uid=sa;pwd=sas;DSN=Wareho use;RO=Tru e;FBS=50;"
con.Open
SQL = "Select pt_part, pt_desc1 From PT_MSTR where pt_part like '1%'"
Set res = con.Execute(sql, ret, adCmdTable)
cnt = 0
While res.EOF = False
tval = res(0).Value
If Instr(1, tval, "40477", 0) > 0 Then
tval = res(0).Value
End If
tDesc = res(1).Value
Set tdoc = ItemView.getDocumentbyKey( tval)
If tdoc Is Nothing Then
Set tdoc = db.CreateDocument
tdoc.Form = "(Items)"
tdoc.ItemNumber = tval
tdoc.ItemDesc = tDesc
Call tdoc.Save(True, True)
End If
cnt = cnt + 1
res.MoveNext
Wend
res.Cancel
con.Cancel
con.Close
' Else
' Set con = CreateObject("MicrosoftRDO .RdoConnec tion2.0")
' con.close
' con.Connect = "uid=sa;pwd=sas;DSN=Wareho use;RO=Tru e;FBS=50;"
' con.cursordriver = 1
' con.EstablishConnection 1
' SQL = "Select pt_part, pt_desc1 From PT_MSTR where pt_part like '4%'"
' Set rs = con.OpenResultSet(SQL,rdOp enDynamic, rdConcurRe adOnly)
' cnt = 0
' rs.MoveNext
' While rs.EOF = False
' tval = rs(0).Value
' tDesc = rs(1).Value
' Set tdoc = ItemView.getDocumentbyKey( tval)
' If tdoc Is Nothing Then
' Set tdoc = db.CreateDocument
' tdoc.Form = "(Items)"
' tdoc.ItemNumber = tval
' tdoc.ItemDesc = tDesc
' Call tdoc.Save(True, True)
' End If
'
' cnt = cnt + 1
' rs.MoveNext
'
' Wend
' rs.close
' con.close
' End If
End Sub
-------------------------- ---------- ---------- ---------- ---------- ----
I need to connect to a DECS connection already established. (same name).
--------------------------
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim EODMark As String, tempPONumb As String, currPO As String, povend As String, postat As String, sql As String
Dim GetNextPO As Integer
Dim poline As Integer, cnt As Integer
Dim tdoc As NotesDocument
Dim ItemView As NotesView
Dim tempdate As Variant
Dim datediff As Double
Dim ret As Long
Dim cmd As Variant
Dim cols As Variant
Dim tval As Variant
Dim tDesc As Variant
Set db = session.CurrentDatabase
Set ItemView = db.GetView("(Items)")
' ret = Messagebox("Use ADO (Yes) or RDO (No)", 4, "Question")
' If ret = 6 Then
Set con = CreateObject("ADODB.Connec
Set res = CreateObject("ADODB.Record
If con.State = adStateOpen Then
res.Cancel
con.Cancel
End If
con.ConnectionString = "uid=sa;pwd=sas;DSN=Wareho
con.Open
SQL = "Select pt_part, pt_desc1 From PT_MSTR where pt_part like '1%'"
Set res = con.Execute(sql, ret, adCmdTable)
cnt = 0
While res.EOF = False
tval = res(0).Value
If Instr(1, tval, "40477", 0) > 0 Then
tval = res(0).Value
End If
tDesc = res(1).Value
Set tdoc = ItemView.getDocumentbyKey(
If tdoc Is Nothing Then
Set tdoc = db.CreateDocument
tdoc.Form = "(Items)"
tdoc.ItemNumber = tval
tdoc.ItemDesc = tDesc
Call tdoc.Save(True, True)
End If
cnt = cnt + 1
res.MoveNext
Wend
res.Cancel
con.Cancel
con.Close
' Else
' Set con = CreateObject("MicrosoftRDO
' con.close
' con.Connect = "uid=sa;pwd=sas;DSN=Wareho
' con.cursordriver = 1
' con.EstablishConnection 1
' SQL = "Select pt_part, pt_desc1 From PT_MSTR where pt_part like '4%'"
' Set rs = con.OpenResultSet(SQL,rdOp
' cnt = 0
' rs.MoveNext
' While rs.EOF = False
' tval = rs(0).Value
' tDesc = rs(1).Value
' Set tdoc = ItemView.getDocumentbyKey(
' If tdoc Is Nothing Then
' Set tdoc = db.CreateDocument
' tdoc.Form = "(Items)"
' tdoc.ItemNumber = tval
' tdoc.ItemDesc = tDesc
' Call tdoc.Save(True, True)
' End If
'
' cnt = cnt + 1
' rs.MoveNext
'
' Wend
' rs.close
' con.close
' End If
End Sub
--------------------------
ASKER
OK...we havn't had this script running in a while and we have since changed boxes.
There wasn't a DSN set up on the box the parameters of which are not known.
All we know is it ran fine.
Now, there is a SQL DSN set up on the box and it checks out.
Not sure what we're missing to make th above script work, but when I invoke DEBUG, it bombs at the line " Set con = CreateObject("ADODB.Connec tion.2.5") "
I don't know enough at this point to be able to know why.
It was suggested that we use DECS, but again, I'm swirling and don't know how to employ it correctly.
I'd like to leave the script as is and get whatever I'm missing going on the other end.
There wasn't a DSN set up on the box the parameters of which are not known.
All we know is it ran fine.
Now, there is a SQL DSN set up on the box and it checks out.
Not sure what we're missing to make th above script work, but when I invoke DEBUG, it bombs at the line " Set con = CreateObject("ADODB.Connec
I don't know enough at this point to be able to know why.
It was suggested that we use DECS, but again, I'm swirling and don't know how to employ it correctly.
I'd like to leave the script as is and get whatever I'm missing going on the other end.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, DECS can't be scripted -- you basically tel it what you want tomatch up, and it either maps or it does not map. You can't do much logic in it. If you want logic, you have to go with LEI. Or you can use LSXLC, which is the DECS connection but using LotusScript (similar to ADO). However, DECS and LEI both run at the server, while LSXLC runs at the client. (LSXLC can run on the server, but there is simple way to trigger it without LEI).
Why don't you explain WHY you need to switch ADO to DECS, and what the context ofthe bussiness case is?