
RTF save using ADO / COM to Access / SQL database
Just for the record - I solved it.
the correct code is:
'------------------------------------------------
Dim RptId As Double
Dim recs As Long
Const gMEMOSIZE = 2147483647
Dim objCmd As ADODB.Command
Set objCmd = New ADODB.Command
objCmd.CommandText = "qryUpdReportTxt"
objCmd.CommandType = adCmdStoredProc
' Connect to the data source.
objCmd.ActiveConnection = oConn
RptId = 20
objCmd.Parameters.Append objCmd.CreateParameter("ReportId", adDouble,
adParamInput, , RptId)
objCmd.Parameters.Append objCmd.CreateParameter("ReportText",
adLongVarWChar, adParamInput, gMEMOSIZE, Me.RichTextBox1.TextRTF)
objCmd.Execute
'objCmd.Execute recs, objCmd.Parameters
' -----------------------------------------------
the Access "stored procedure" (actually a query def with params) is:
PARAMETERS ReportId IEEEDouble, ReportText Text ( 255 );
UPDATE tblreports SET tblreports.ReportText = [ReportText]
WHERE (((tblreports.RepId)=[ReportId]));
- however the underlying field tblReports.ReportText is a memo field.
The problem is, if you define the [ReportText] param as a memo - it
will not work! (or define it as "ReportText text" as you would in MS
SQL)
Further, if you use the MSDN described procedure to call the Access
stored procedure, (objCmd.Execute recs, objCmd.Parameters) it will not
work either.
Even though the param is defined as Report (255) I have tested it with
a 4,000 char RTF variable and it stored it OK.
Having followed the MSDN and previous usergroup postings, I have
managed to waste 3 full days of time :-( no wonder no-one reads the