RTF save using ADO / COM to Access / SQL database 
Author Message
 RTF save using ADO / COM to Access / SQL database

Hi all,

I am trying to save a RTF using ADO back to a middle tier COM server.
The "pr0of of concept" phase has an Access2000 mdb as the remote db,
but I shall be deploying with MS SQL V7 later.
The db has a stored procedure with parameters: ReportId long and
ReportText memo.

When I try (as per an earlier posting with regard to a similar
question posed to the group):

Const gMEMOSIZE = 2147483647
Dim recs As Long
Dim objCmd As ADODB.Command
Set objCmd = New ADODB.Command

objCmd.CommandText = "qryUpdReportTxt"
objCmd.CommandType = adCmdStoredProc

' Connect to the data source.
objCmd.ActiveConnection = oConn 'previously declared connection

objCmd.Parameters.Append objCmd.CreateParameter("ReportId",
adVarNumeric, adParamInput, 20000, "22")
objCmd.Parameters.Append objCmd.CreateParameter("ReportText",
adLongVarWChar, adParamInput,gMEMOSIZE, Me.RichTextBox1.TextRTF)
' Me.RichTextBox1 is the field on the form with the rich text

objCmd.Execute recs, objCmd.Parameters, -1

Exit Sub

I get:

run time error:
-2147217887 [Microsoft][ODBC Microsoft Access Driver] Restricted Data
Type attribute violation

if I try
objCmd.Execute
then the error becomes:
run time error:
-2147217887 (same as above error number!)
Multiple-step OLE DB operation generated errors. Check each OLE DB
status value, if available. No work was done.

I have spoent 3 days trolling through the MSDN & Google usergroups
looking for this, but have hit a wall.

Any help would be much appreciated.
Frustrated.



Tue, 17 Aug 2004 06:48:43 GMT  
 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



Tue, 17 Aug 2004 13:29:09 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. save objects to an Access database using ADO

2. Saving Rich Text Format (RTF) in Oracle 10g using PL/SQL via VB/ASP.NET

3. SQL Database access using ado

4. Access to SQL/Oracle database using ADO and linked table

5. Saving .rtf in an access database

6. Saving images out of SQL 7 to disk using ADO

7. How to save an VB PaintBrush Picture in SQL 6.5 using ADO

8. Saving images in a SQL Server DB using ADO

9. Saving images out of SQL 7 to disk using ADO

10. Saving VB pictures in SQL using ADO

11. Accessing Access with database level password using ADO

12. ADO using MS Access with mdw system database for pw-access

 

 
Powered by phpBB® Forum Software