INSERT INTO ADO ODBC

manumanu Member Posts: 4
edited 2001-12-12 in Navision Financials
Nearly finished with a small project I am working on to export attachments from Outlook directly into Navision. Through
the Navision ODBC I can SELECT, UPDATE sucsessfully but I cannot seem to INSERT rows into the database.

The code which is supposed to do this follows:

DocID = GetNextNumber()
strImagePath = Trim$(FileNamePath)
Dim bytBLOB() As Byte

sConnPar = "DSN=Outlook"
Set cnData = CreateObject("adodb.connection")
Set rsDocument = CreateObject("adodb.recordset")
cnData.Open sConnPar
rsDocument.Open "SELECT * FROM Dokument WHERE ""No.""='D'", cnData, 2, 3

With rsDocument
.Addnew
.fields("No.") = DocID
.fields("Modified Date") = Date
.fields("Batch") = True
.fields("Sales Document Type") = "0"
.fields("Purchase Document Type") = "0"
.fields("Prospect No.") = Prospektnr
'Open the picture file
intNum = FreeFile
Open strImagePath For Binary As #intNum
ReDim bytBLOB(FileLen(strImagePath))
'Read data and close file
Get #intNum, , bytBLOB
Close #1
'Store the BLOB
.fields("Innehåll").AppendChunk bytBLOB
.Update
End With

Set rsDocument = Nothing
cnData.Close
Set cnData = Nothing

Every time I run this I get an
lexical element expected: )
error message.

The ODBC connection is set to allow
BLOB fields and read only is turned off.

Any good ideas anyone?

PS: I am not much of a navision developer.

Many thanks in advance

Manuel Fraga

Comments

  • hshs Member Posts: 4
    Hi,
    I think your problem is, that your opening a selection, where you hardly can add a new record, so open a real table.
    e.g. rsDocument.Open "YourTableName", cnData, 2, 3, 2 (the last parameter (2) indicated to deal with a tablename
Sign In or Register to comment.