Hello,
I want to insert documents from notes into an already existing sql table.
The first field INCIDENTNUM is my key field and it is an auto increment field. It should advance to the next sequencial number when a new record is inserted. I do not want notes to update this field so I set the flag to LCFIELDF_NO_INSERT. When I run my code. I get the
error: Field type mismatch “INCIDENTNUM” Source Connector field is type Text. Target Connector field is type numeric.
How can I insert the records into sql and make the key field INCIDENTNUM advance to the next sequential number.
Here is my code, I would appreciate any help in solving this. Thanks,
%INCLUDE “LSERR.LSS”
Sub Initialize
Dim doc As NotesDocument
Dim db As NotesDatabase
Dim session As New NotesSession
Dim src As LCConnection
Dim dc As NotesDocumentCollection
'Dim outFlist As New LCFieldList
Dim FldList As New LCFieldList
Dim incident As LCField
Dim request As LCField
Dim firstn As LCField
Dim middleint As LCField
Dim lastn As LCField
Dim titleQ As LCField
Dim acctnom As LCField
Dim address As LCField
Dim city As LCField
Dim zip As LCField
Dim hphone As LCField
Dim count As Long
count = 0
Set db = Session.GetDatabase( "server","database.nsf")
'used to run agent on server:
'set connection to your sql table
Set src = New LCConnection ( "oledb")
src.Provider = "SQLOLEDB"
src.server = "server"
src.Userid = "id"
src.Password = "pass"
src.database = "dbname"
src.metadata = "tablename"
src.Connect
Set incident = FldList.Append("INCIDENTNUM", LCTYPE_NUMERIC)
incident.Flags = LCFIELDF_NO_INSERT
Set request = FldList.Append("REQUESTID", LCTYPE_NUMERIC)
Set firstn = FldList.Append("FIRSTNAME", LCTYPE_TEXT)
Set middleint = FldList.Append("MIDDLEINITIAL", LCTYPE_TEXT)
Set lastn = FldList.Append("LASTNAME", LCTYPE_TEXT)
Set titleQ = FldList.Append("TITLE", LCTYPE_TEXT)
Set acctnom = FldList.Append("ACCTNUM", LCTYPE_TEXT)
Set address = FldList.Append("CUSTADDRESS", LCTYPE_TEXT)
Set city = FldList.Append("CUSTCITY ", LCTYPE_TEXT)
Set zip = FldList.Append("CUSTZIP", LCTYPE_TEXT)
Set hphone = FldList.Append("HOMEPHONE", LCTYPE_TEXT)
'search for documents in database that meets requirement
Set dc = db.Search(|form = "Departments"|,Nothing,0)
Set doc =dc.GetFirstDocument
Msgbox ("Count " & dc.count)
While Not doc Is Nothing
request.Value = "600"
firstn.value = doc.Fname(0)
middleint.value = doc.Initial(0)
lastn.value = doc.Lname(0)
titleQ.value = ""
acctnom.Value = "import"
address.value = doc.Address(0)
city.value = "doc.City(0)"
zip.value = "doc.Zip(0)"
hphone.value = doc.Phone(0)
count = src.Insert(FldList)
Msgbox "Inserted row"
Wend
src.Disconnect
Msgbox "Done with sql"
End Sub