Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

really weird problem using sp_OAMethod

Status
Not open for further replies.

CW2002

Programmer
Jun 28, 2002
16
AU
I have a COM component written in VB, that are invoked in a stored proc on a
SQL Server.

The function prototype for the COM component that I am calling is :

Public Function RunTemplateToPDF(ByVal ModelTemplate As String, ByVal
ModifiedTemplate As String, ErrorMsg As String, ByVal PS2 As String, ByVal
PDF As String, ByVal PS2PDFExe As String) As Long


I call this from a stored proc as

...
declare @retval int
declare @olehandle int
declare @methodretval int
declare @modeltemplate varchar(50)
declare @modifiedtemplate varchar(50)
declare @errormsg varchar(255)
declare @ps2port varchar(50)
declare @pdffilepath varchar(50)
declare @ps2pdfpath varchar(50)
declare @source varchar(255)
declare @description varchar(255)
...
exec @retval=sp_oamethod @olehandle, 'runtemplatetopdf', @methodretval out,
@modeltemplate, @modifiedtemplate, @errormsg out, @ps2port,
@pdffilepath, @ps2pdfpath

if @retval<>0
begin
exec sp_oageterrorinfo @olehandle, @source out, @description out
set @errormsg='error executing runtemplatetopdf: ' + @description + '
from ' + @source
print @errormsg
end

Now often I get the following error after calling sp_oamethod:
-2147211489: error executing runtemplatetopdf: The source data specified for
this string or binary column or parameter is too long. from ODSOLE Extended
Procedure
where -2147211489 is the @retval from calling sp_OAMethod.

The error message seems to suggest that there are some type mismatches
between calling arguments in my stored proc, and that accepted by the COM
object. However, I certainly couldn't tell any problem here.

Now the bizzare part of it is that, to fix the errors I have been getting, I
could do 2 things:

(1) stop and start SQL Server. After doing that, @retval=0 and everything
works fine.

(2) place the VB COM object in debug mode. Again after doing that, the
stored proc will run happily without any issue.

As to when the error starts reapparing? I don't really know. It seems to
happen after not running the stored proc for a while, and start running it
again.

I looked up the MS Knowledge base, and can't find anything similar to what I
have described. I am using SQL 2K.

Thanks in advance



 
Figured out the problem

ErrorMsg was being passed out, and its size exceeds 255 characters, and thus the error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top