We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.word in sql server CLR

Hello

I want to have a Sql Server CLR, written in VB. I want to run Aspose.Word in the CLR. I want to run a aspx web page that will call a CLR, which in turn will generate a Aspose.Word mail merge document that can saved on a server.

I did not see any examples so I am wondering if this can be done. Any assistents would be helpful.

My CLR looks like

Imports System

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports Microsoft.SqlServer.Server

Partial Public Class StoredProcedures

_

Public Shared Sub CF_LIST_ANNUITY_LOYALTY_TRACKING_CLR_SP()

Try

Dim sqlConnection As SqlConnection = New SqlConnection("context connection=true")

Dim lt As New loyalityTracking

Dim createDateTime As DateTime

Dim createDateTimeStr As String

Dim _dt As New DataTable

Dim _cmd As New SqlCommand

Dim _adpt As New SqlDataAdapter

Dim errorOccurred As Boolean = False

Dim errorMessage As String = ""

sqlConnection.Open()

createDateTimeStr = "06/22/2010"

createDateTime = CDate(createDateTimeStr)

_dt = lt.CF_STMT_BILLING_VANISH_LTR_GENERATE_PASS_LETTERS_SP(sqlConnection, createDateTime, errorOccurred, errorMessage)

If errorOccurred <> True Then

'Aspose.Word for generating document from _dt

End If

Catch ex As Exception

End Try

End Sub

Public Class loyalityTracking

Public Function CF_STMT_BILLING_VANISH_LTR_GENERATE_PASS_LETTERS_SP(ByVal sqlConnection As SqlConnection, ByVal createDateTime As DateTime, _

ByRef errorOccurred As Boolean, ByRef errorMessage As String) As DataTable

Dim _dt As New DataTable

Dim _cmd As New SqlCommand

Dim _adpt As New SqlDataAdapter

errorOccurred = False

_cmd = New SqlCommand("CF_STMT_BILLING_VANISH_LTR_GENERATE_PASS_LETTERS_SP", sqlConnection)

_cmd.CommandType = CommandType.StoredProcedure

_cmd.Parameters.AddWithValue("@PROCESS_DATE", createDateTime)

_cmd.CommandTimeout = 0

Try

_adpt = New SqlDataAdapter

_adpt.SelectCommand = _cmd

_adpt.Fill(_dt)

Catch ex As Exception

errorOccurred = True

errorMessage = ex.Message

End Try

Return _dt

End Function

End Class

End Class

Thanks

Kevin

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank youfor your interest in Aspose.Words. You can find a lot of examples in the documentation. Here you can find simple example, which shows how to execute mail merge:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-execute-simple-mail-merge.html

As you can see, to execute mail merge you need to have template and datasource. Nothing else is required. So I think, you can easily achieve what you need in your CLR.

Best regards.

Alexey

The problem is not creating a code for the mail merge but getting Aspose.Word dll to be reference in the CLR program itself. Since I cannot reference the Aspose.Word dll I cannot compile my CLR.

So the question is how do I add the Aspose.Word dll reference to a Visual Studio Sql stored procedure (CLR)?

Thanks

Kevin

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. You cannot add reference to dll into SQL Server Project, you can only refer to another SQL Server Projects. So you cannot use Aspose.Words or any other dlls in SQL Server Project.

Best regards.