?
Solved

Winfax from a SQL SP

Posted on 2003-03-03
14
Medium Priority
?
317 Views
Last Modified: 2012-06-21
..
0
Comment
Question by:AT_TAC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

743 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