?
Solved

Winfax from a SQL SP

Posted on 2003-03-03
14
Medium Priority
?
324 Views
Last Modified: 2012-06-21
..
0
Comment
Question by:AT_TAC
14 Comments
 
LVL 23

Expert Comment

by:adathelad
ID: 8056278
Could you post more info?
0
 

Author Comment

by:AT_TAC
ID: 8056298
Hi

I am trying to send a fax to a winfax server using a SQL 200 SP. I am using Winfax Pro V10 (the SDK) and Win2k.

I can create the object and even set some of the simple properties eg Use a cover page or not (SetUSeCover) but when I try to set a property eg the cover text (SetCoverText) I get an error which translates to TYPE MISMATCH.

Below is my code

alter PROCEDURE SendFax
      (
      @Body             VARCHAR(255),
      @Subject      VARCHAR(100),
      @To            VARCHAR(100),
      @Error            VARCHAR(255) OUT
      )
AS

      DECLARE            @SPError      INT,
                  @ObjID            INT,      
                  @x            INT,
                  @PropertyError varchar(50)


      SET            @SPError = 0
      SET            @ObjID = 0
      SET            @Error = ''
      SET            @x = 0

      -- This Works
      EXEC @SPError = sp_OACreate 'Winfax.SDKSend8.0', @ObjID OUT
      WAITFOR DELAY '00:00:05'
      IF @SPError <> 0
            BEGIN
                  SET @Error = 'Error creating object Winfax.SDKSend8.0'
                  GOTO TheEnd
            END
      print 'Objected Created'



      -- This Works
      EXEC sp_OASetProperty @ObjID, 'LeaveRunning'
      PRINT @propertyError
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Error leaverunning'
                  GOTO TheEnd
            END

      -- This Works
      EXEC sp_OASetProperty @ObjID, 'SetUSeCover', 1
      PRINT @propertyError
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Error setusecover'
                  GOTO TheEnd
            END

      -- This Works
      EXEC sp_OASetProperty @ObjID, 'Setquickcover', 1
      PRINT @propertyError
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Error setquickcover'
                  GOTO TheEnd
            END

      -- This Works
      EXEC sp_OASetProperty @ObjID, 'SetUSeCover', 1
      PRINT @propertyError
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Error setusecover'
                  GOTO TheEnd
            END

      -- This Works
      EXEC sp_OASetProperty @ObjID, 'SetPrintFromApp', 1
      PRINT @propertyError
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Set Print from aPP Error'
                  GOTO TheEnd
            END
      


      -- This Works
      EXEC @PropertyError = sp_OAGetProperty @ObjID, 'Setusecover', @Body OUT, 1
      print @body
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Error GETTING property SetCoverText'
                  GOTO TheEnd
            END
      print @body

      -- This doesn't work
      EXEC @PropertyError = sp_OASetProperty @ObjID, 'SetCoverText', @Body OUT
      print @propertyerror
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Error setting property SetCoverText'
                  GOTO TheEnd
            END



      -- This doesn't work
      EXEC @PropertyError = sp_OASetProperty @ObjID, 'SetSubject', @Subject
      IF @PropertyError <> 0
            BEGIN
                  SET @Error = 'Error setting property SetSubject'
                  GOTO TheEnd
            END
      
      -- This doesn't work
      EXEC @PropertyError = sp_OASetProperty @ObjID, 'SetNumber', 123456
      PRINT @propertyError
      IF @PropertyError <> 0
            BEGIN
                  execute sp_displayoaerrorinfo @ObjID, @PropertyError            
                  SET @Error = 'Error setting property SetNumber'
                  GOTO TheEnd
            END
      
      EXEC @PropertyError = sp_OASetProperty @ObjID, 'AddRecipient'

      IF @PropertyError <> 0
            BEGIN
                  SET @Error = 'Error setting property AddRecipient'
                  GOTO TheEnd
            END

      EXEC @PropertyError = sp_OAMethod @ObjId, 'Send', NULL, 0
      IF @PropertyError <> 0
            BEGIN
                  SET @Error = 'Error sending fax'
            END
      ELSE
            SET @Error = 'Fax Sent'

      THEEND:
      PRINT @Error
      IF @Error <> 'Error creating object Winfax.SDKSend8.0'
            EXEC @x = sp_OADestroy @ObjId



0
 
LVL 18

Expert Comment

by:nigelrivett
ID: 8056342
Have you tride it from VB?

It may be easier to create a com wrapper in VB and call that.

If I have problems I often use VB to find what the calls should be as it gives more info than t-sql. Then convert the calls to sql.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 

Author Comment

by:AT_TAC
ID: 8056351
I have tried it from VB and it works no problems at all.

I could get someone to write a com wrapper in VB for me but the how do I call this from my stored procedure and pass it variables?
0
 
LVL 23

Expert Comment

by:adathelad
ID: 8056356
Ok....

The first blobak that fails:
EXEC @PropertyError = sp_OASetProperty @ObjID, 'SetCoverText', @Body OUT

The 3rd parameter should be the value to set the SetCoverText property to, but you have it as an output parameter. Should it not be?
EXEC @PropertyError = sp_OASetProperty @ObjID, 'SetCoverText', 'Cover Text Here'


0
 

Author Comment

by:AT_TAC
ID: 8056373
I have tried it as just text as in your example also just as the variable @body both without the OUT at the end but I still get the same error.

Here is the error, the first line is the error code which translates below that.

-2147352571
OLE Automation Error Information
  HRESULT: 0x80020005
  Source: ODSOLE Extended Procedure
  Description:  Type mismatch.
0
 
LVL 23

Expert Comment

by:adathelad
ID: 8056400
does it make any difference if you pass the value in as a unicode value?
e.g.
EXEC @PropertyError = sp_OASetProperty @ObjID, 'SetCoverText', N'Cover Text Here'
0
 

Author Comment

by:AT_TAC
ID: 8056410
Hi adathelad

I just tried your example :
EXEC @PropertyError = sp_OASetProperty @ObjID, 'SetCoverText', N'Cover Text Here'
and got the same error?
0
 

Expert Comment

by:CleanupPing
ID: 9276200
AT_TAC:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 23

Expert Comment

by:adathelad
ID: 9278121
Recommend: points refund
0
 

Author Comment

by:AT_TAC
ID: 9285707
I wrote a wrapper in VB 6 and then called this object from within the SP and it worked fine. This is a round about solution but I had no other choice, I needed to get it working.
0
 

Author Comment

by:AT_TAC
ID: 9285711
I wrote a wrapper in VB 6 and then called this object from within the SP and it worked fine. This is a round about solution but I had no other choice, I needed to get it working.
0
 
LVL 12

Expert Comment

by:monosodiumg
ID: 10994220
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    PAQ with points refunded

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

monosodiumg
EE Cleanup Volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 11135871
PAQed, with points refunded (75)

Computer101
E-E Admin
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question