473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Logon Error

OK why does the following code work in a Windows form with a crystal report
viewer but not in a webform. I get the usual
CrystalReports.EngineLogONException logon Failed when this is called in aspx.

Any help will be very much apprecaited

Alixx

This is the code in the calling aspx Page

Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.CrystalReports.Engine

Public Class Order
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Protected WithEvents WebViewer As CrystalDecisions.Web.CrystalReportViewer
Protected WithEvents PrintReport As System.Web.UI.WebControls.ImageButton
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim DoReport As New Order_Class
DoReport.SetCompany = "BK"
DoReport.SetEmail = "te**********@hotmail.com"
DoReport.SetOrderNumber = "223"
Dim szResponse As String = DoReport.CreateOrder()
Dim MyReport As ReportDocument
MyReport = DoReport.EmailPDF

Me.WebViewer.ReportSource = MyReport

End Sub

End Class

Ok this is the start of the code for the class that I call the main
function is emailPDFwhich calls ChangeLogOnInfo EmailPDF returns a Report
Document which so that it can be viewed; eventually it will be exported as
PDF as well(note I have tried just exporting it but doesnt seem to work).

#Region "Imports_Declared"
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlCommand
Imports System.Data.SqlClient.SqlConnection
Imports System.IO.BinaryWriter
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Web
Imports CrystalDecisions.Windows.Forms
Imports System.Web
Imports System.Web.Mail
Imports System.Diagnostics
Imports Microsoft.Win32
Imports System.Runtime.InteropServices
Imports System.Security.Principal
#End Region
#Region "Boiler_Plate"
'################################################# #######################
'# Web Order Class Version 2.0 #
'# Created By Alixx Skevington #
'# #
'# This will create the XML dcoument that is needed for Khaos #
'# That will eventually automatically imported into the database #
'# Then Automatically email's the customer and the shop #
'# And also displays a copy of the report to have it printed #
'# Revision History None #
'################################################# #######################
#End Region

Public Class Order_Class

Public Enum CompanyInfo
AGS
BK
OTHER
End Enum

#Region "Global Variables Declared"
Dim szErrorMailPrimary As String ' This is where all the mail messages
will go
Dim szErrorMailSecondary As String 'This is where all the mail messages
will go to make sure soembody gets them
Dim szMailServer As String 'this is the address of the mail server
Dim szMailFrom As String 'this is who the mail is from
Dim szPathToPDF As String
Dim szPathToExport As String
Dim szKhaosConnectionString As String
Dim szAGSConnectionString As String
Dim szImpersonateContext As
System.Security.Principal.WindowsImpersonationCont ext
Dim szServer As String
Dim szDatabase As String
Dim szUserName As String
Dim szPassword As String
Dim M_Company As String ' This will allow you to set the company to know
which report to use
Dim M_EmailAddress As String 'This is the email address that the user
uses for their login
Dim M_OrderNumber As String 'This is the Order Number that they Use
Dim M_Report As ReportDocument ' This is the variable that declares the
report to be passed back

Dim MainReport As ReportDocument 'This is the Main report that the rest
of the code will use

#End Region


Public Property SetCompany() As String
'<PARA>
' This property is the first property that must be called from the
Order.aspx page as it is the one that is used to define
'the correct report to use
'</PARA>
'<VALUE>
'AGS
'BK
'OTHER
'</VALUE>
Get
SetCompany = M_Company
End Get
Set(ByVal Value As String)
M_Company = UCase(Value)
Select Case M_Company
Case "AGS"
MainReport = New AGS_WEB_ORDER
Case "BK"
MainReport = New BK_WEB_ORDER
Case "OTHER"
MainReport = New OTHER_WEB_ORDER
End Select
End Set

End Property
Public Property SetEmail() As String
'<PARA>
' This property is the first property that must be called from the
Order.aspx page as it is the one that is used to define
'the email address to use for the email address
'</PARA>
'<VALUE>
'm*@here.com
'</VALUE>
Get
SetEmail = M_EmailAddress
End Get
Set(ByVal Value As String)
M_EmailAddress = Value
End Set

End Property
Public Property SetOrderNumber() As String
'<PARA>
'Pass this the order number
'</PARA>
'<VALUE>
'OrderNumber
'</VALUE>
Get
SetOrderNumber = M_OrderNumber
End Get
Set(ByVal Value As String)
M_OrderNumber = Value
End Set

End Property
Public ReadOnly Property Report() As ReportDocument
'<PARA>
'This passeds the report back to Order.aspx
'</PARA>
'
Get
Report = MainReport
End Get
End Property

Private Sub ReadRegistry()
Dim ParentKey As RegistryKey = Registry.LocalMachine
Dim SubKey As String = "SOFTWARE\KHAOS_PDF_EXPORT"
Dim Key As RegistryKey

Try
'Open the registry key.
Key = ParentKey.OpenSubKey(SubKey, True)
If Key Is Nothing Then 'if the key doesn't exist
Throw New Exception("The registry key doesn't exist")
End If

'Get the value.
szErrorMailPrimary = CType(Key.GetValue("MainErrorMail"), String)
szErrorMailSecondary = CType(Key.GetValue("SecondErrorMail"),
String)
szMailServer = CType(Key.GetValue("MailServerIPAddress"), String)
szMailFrom = CType(Key.GetValue("MailFromAddress"), String)
szPathToPDF = CType(Key.GetValue("PathToPDF"), String)
szPathToExport = CType(Key.GetValue("PathToExport"), String)
szKhaosConnectionString =
CType(Key.GetValue("ConnectionString"), String)
szAGSConnectionString =
CType(Key.GetValue("AGSConnectionString"), String)
szServer = CType(Key.GetValue("Server"), String)
szDatabase = CType(Key.GetValue("DB"), String)
szUserName = CType(Key.GetValue("User"), String)
szPassword = CType(Key.GetValue("Password"), String)
Catch e As Exception
'EventLog.CreateEventSource("KhaosXML", "Unable to Pen Khaos
Registry Settings. The following error occured " & e.Message,
EventLogEntryType.Error,1970)
MsgBox(e.Message)
'TODO Put proper error trapping in
End Try
End Sub

Private Sub ErrorMail()
'This is the function that sends an email to the relevant people in
the event of a failure
Try
Dim sysMessage As New MailMessage
sysMessage.From = szMailFrom
sysMessage.To = szErrorMailPrimary
sysMessage.Cc = szErrorMailSecondary
sysMessage.Subject = "WARNING WARNING - ERROR WITH WEB ORDER"
Dim szBody As String
szBody = szBody & "There has been a problem recorder in the
evvent log of the database server." & vbCrLf
szBody = szBody & "This event log warning will tell you what has
gone wrong and where." & vbCrLf
szBody = szBody & "Please inform an administrator as soon as
possible please." & vbCrLf & vbCrLf
sysMessage.Body = szBody
SmtpMail.SmtpServer = szMailServer
SmtpMail.Send(sysMessage)
Catch ex As Exception
EventLog.WriteEntry("KhaosXML", "Unable to email PDF. The
following error occurred " & ex.Message, EventLogEntryType.Error, 1970)
Exit Sub
End Try
End Sub

Function EmailPDF() As ReportDocument

'This creates the fucntion that emails the PDF to the customer

Dim exportFilePath As String
Dim oguid As Guid
Dim szFileName As String = oguid.NewGuid.ToString
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Dim iCount As Integer

Try

MainReport = ChangeLogOnInfo(MainReport, "HERA", "reporter",
"reporter")

'OK We know set the parameters required by the report

Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
crParameterFieldDefinitions =
MainReport.DataDefinition.ParameterFields

crParameterFieldLocation =
crParameterFieldDefinitions.Item("OrderNumber")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New
CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = M_OrderNumber
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crPara meterValues)

MainReport = ChangeLogOnInfo(MainReport, "HERA", "reporter",
"reporter")

'MainReport.PrintToPrinter(1, False, 1, 1)
'Try
' Dim sysMessage As New MailMessage
' sysMessage.From = szMailFrom
' sysMessage.To = M_EmailAddress
' sysMessage.Subject = "Confirmation of Order at The Adult Gift
Shop Limited"
' Dim szBody As String
' szBody = szBody & "We enlose a PDF version of your order for
your records." & vbCrLf
' szBody = szBody & "If you do not have adobe acrobat reader
installed please click on the link below to install it" & vbCrLf
' szBody = szBody &
"http://www.adobe.com/products/acrobat/readstep2.html" & vbCrLf & vbCrLf
' szBody = szBody & "Please do not reply to this email address
all emails. Should be addressed to en*****@theadultgiftshop.com" & vbCrLf
' szBody = szBody & vbCrLf & vbCrLf & "Thankyou for shopping at
the Adult Gift Shop"
' sysMessage.Body = szBody
' Dim sysAttachment As MailAttachment = New
MailAttachment(exportFilePath, MailEncoding.Base64)
' sysMessage.Attachments.Add(sysAttachment)
' SmtpMail.SmtpServer = szMailServer
' SmtpMail.Send(sysMessage)

' If IO.File.Exists(exportFilePath) Then
' IO.File.Delete(exportFilePath)
' End If

'Catch ex As Exception
' EventLog.WriteEntry("KhaosXML", "Unable to email PDF. The
following error occurred " & ex.Message & "Order Number " & M_OrderNumber & "
Email Address " & M_EmailAddress & ".", EventLogEntryType.Error, 1970)
' ErrorMail()
' Exit Function
'End Try

Catch ex As Exception
MsgBox(ex.Message)
End Try
Return MainReport

End Function
Private Function ChangeLogOnInfo(ByVal Report As ReportDocument, ByVal
ServerName As String, ByVal UserName As String, ByVal Password As String) As
ReportDocument
Dim crConnectionInfo As New ConnectionInfo
With crConnectionInfo
.ServerName = ServerName

.UserID = UserName
.Password = Password
End With

Dim crTable As Table
Dim LogOnInfo As TableLogOnInfo
For Each crTable In Report.Database.Tables
LogOnInfo = crTable.LogOnInfo
'Debug.Write(crTable.Name)
''OK If I get this right we dont need to chnage database names
but will need to chnage servers and usernames and passwords as we
'' may have subreports pointing to different areas

'LogOnInfo.ConnectionInfo.DatabaseName = Database

LogOnInfo.ConnectionInfo.ServerName = ServerName
LogOnInfo.ConnectionInfo.UserID = UserName
LogOnInfo.ConnectionInfo.Password = Password
'LogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(LogOnInfo)
Next
'OK AND NOW WE DO THE SUB REPORTS
Dim crReportObject As ReportObject
Dim crReportObjects As ReportObjects
Dim crSection As Section
Dim crSections As Sections
Dim SubReportObject As SubreportObject
Dim subReportDocument As ReportDocument
Dim crSubTable As Table
Dim crSubTables As Tables
Dim crSubLogOnInfo As TableLogOnInfo
crSections = Report.ReportDefinition.Sections

For Each crSection In crSections
crReportObjects = crSection.ReportObjects

For Each crReportObject In crReportObjects

If TypeOf crReportObject Is SubreportObject Then
SubReportObject = CType(crReportObject, SubreportObject)
subReportDocument =
SubReportObject.OpenSubreport(SubReportObject.Subr eportName)

crSubTables = subReportDocument.Database.Tables

For Each crSubTable In crSubTables
crSubLogOnInfo = crSubTable.LogOnInfo
crSubLogOnInfo = crTable.LogOnInfo
crSubLogOnInfo.ConnectionInfo.ServerName = ServerName
crSubLogOnInfo.ConnectionInfo.UserID = UserName
crSubLogOnInfo.ConnectionInfo.Password = Password
crSubTable.ApplyLogOnInfo(LogOnInfo)
Next
End If
Next
Next

Return Report

End Function
End Class
Nov 18 '05 #1
6 1647
Hi Alex:

This symptom is typical of the one hop limit in NTLM authentication.
I'm not sure what credentials Crystal needs to see, so I can't offer a
solution. There are many ways around the problem if you google for one
hop ntlm asp.net you should see some suggestions.

--
Scott
http://www.OdeToCode.com/

On Tue, 5 Oct 2004 01:53:04 -0700, "Alixx Skevington"
<Al*************@discussions.microsoft.com> wrote:
OK why does the following code work in a Windows form with a crystal report
viewer but not in a webform. I get the usual
CrystalReports.EngineLogONException logon Failed when this is called in aspx.

Any help will be very much apprecaited


Nov 18 '05 #2
Hi Alixx,

Something else I learned today. Crystal allows you to bind to a
DataTable in WinForms but not in ASP.NET. Anychance you are using a
DataTable? Can you switch to a DataGrid?

P.S. Sorry about calling you Alex, the spellchecker must have kicked
in.

--
Scott
http://www.OdeToCode.com/

On Tue, 5 Oct 2004 01:53:04 -0700, "Alixx Skevington"
<Al*************@discussions.microsoft.com> wrote:
OK why does the following code work in a Windows form with a crystal report
viewer but not in a webform. I get the usual
CrystalReports.EngineLogONException logon Failed when this is called in aspx.

Any help will be very much apprecaited

Alixx


Nov 18 '05 #3
Hi Scott,

Thanks for your help thus far, I am still trawling the net for the one hop
problem trying to see if I can make it work that way.

I am not binding to a databale or datagrid, infact I am not trying to do
anything other than change the LogonInfo so that it will connect to a
different server from reading the registry settings and passing it teh
paramter to query the DB on. And then passing this all back to the report
viewer to display.

I wish that the error was more helpful.

Alixx

"Scott Allen" wrote:
Hi Alixx,

Something else I learned today. Crystal allows you to bind to a
DataTable in WinForms but not in ASP.NET. Anychance you are using a
DataTable? Can you switch to a DataGrid?

P.S. Sorry about calling you Alex, the spellchecker must have kicked
in.

--
Scott
http://www.OdeToCode.com/

On Tue, 5 Oct 2004 01:53:04 -0700, "Alixx Skevington"
<Al*************@discussions.microsoft.com> wrote:
OK why does the following code work in a Windows form with a crystal report
viewer but not in a webform. I get the usual
CrystalReports.EngineLogONException logon Failed when this is called in aspx.

Any help will be very much apprecaited

Alixx


Nov 18 '05 #4
Scott,

OK; I have trawled the Net for possible solutions to this problem; I have
tried altering Machine.config. to make the aspne_wp.exe run as a Newtork user
rather than a local Machine user Nada. I have made the website run as a user
that is added to the sqlserver as a authorised user and is even given dbo
rights to the SQL Server. I am at the point of even contemplating sacrificing
a virgin blue chicken on a clear moonlit night to see if this will help.
Surely to god it should not be this difficult to renew logon info for this
seeing as it is dersigned to do it.

I am running SQL Server 2000 in a Windows 2000 AD Domain
"Alixx Skevington" wrote:
OK why does the following code work in a Windows form with a crystal report
viewer but not in a webform. I get the usual
CrystalReports.EngineLogONException logon Failed when this is called in aspx.

Any help will be very much apprecaited

Alixx

This is the code in the calling aspx Page

Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.CrystalReports.Engine

Public Class Order
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Protected WithEvents WebViewer As CrystalDecisions.Web.CrystalReportViewer
Protected WithEvents PrintReport As System.Web.UI.WebControls.ImageButton
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region
Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim DoReport As New Order_Class
DoReport.SetCompany = "BK"
DoReport.SetEmail = "te**********@hotmail.com"
DoReport.SetOrderNumber = "223"
Dim szResponse As String = DoReport.CreateOrder()
Dim MyReport As ReportDocument
MyReport = DoReport.EmailPDF

Me.WebViewer.ReportSource = MyReport

End Sub

End Class

Ok this is the start of the code for the class that I call the main
function is emailPDFwhich calls ChangeLogOnInfo EmailPDF returns a Report
Document which so that it can be viewed; eventually it will be exported as
PDF as well(note I have tried just exporting it but doesnt seem to work).

#Region "Imports_Declared"
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlCommand
Imports System.Data.SqlClient.SqlConnection
Imports System.IO.BinaryWriter
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Web
Imports CrystalDecisions.Windows.Forms
Imports System.Web
Imports System.Web.Mail
Imports System.Diagnostics
Imports Microsoft.Win32
Imports System.Runtime.InteropServices
Imports System.Security.Principal
#End Region
#Region "Boiler_Plate"
'################################################# #######################
'# Web Order Class Version 2.0 #
'# Created By Alixx Skevington #
'# #
'# This will create the XML dcoument that is needed for Khaos #
'# That will eventually automatically imported into the database #
'# Then Automatically email's the customer and the shop #
'# And also displays a copy of the report to have it printed #
'# Revision History None #
'################################################# #######################
#End Region

Public Class Order_Class

Public Enum CompanyInfo
AGS
BK
OTHER
End Enum

#Region "Global Variables Declared"
Dim szErrorMailPrimary As String ' This is where all the mail messages
will go
Dim szErrorMailSecondary As String 'This is where all the mail messages
will go to make sure soembody gets them
Dim szMailServer As String 'this is the address of the mail server
Dim szMailFrom As String 'this is who the mail is from
Dim szPathToPDF As String
Dim szPathToExport As String
Dim szKhaosConnectionString As String
Dim szAGSConnectionString As String
Dim szImpersonateContext As
System.Security.Principal.WindowsImpersonationCont ext
Dim szServer As String
Dim szDatabase As String
Dim szUserName As String
Dim szPassword As String
Dim M_Company As String ' This will allow you to set the company to know
which report to use
Dim M_EmailAddress As String 'This is the email address that the user
uses for their login
Dim M_OrderNumber As String 'This is the Order Number that they Use
Dim M_Report As ReportDocument ' This is the variable that declares the
report to be passed back

Dim MainReport As ReportDocument 'This is the Main report that the rest
of the code will use

#End Region


Public Property SetCompany() As String
'<PARA>
' This property is the first property that must be called from the
Order.aspx page as it is the one that is used to define
'the correct report to use
'</PARA>
'<VALUE>
'AGS
'BK
'OTHER
'</VALUE>
Get
SetCompany = M_Company
End Get
Set(ByVal Value As String)
M_Company = UCase(Value)
Select Case M_Company
Case "AGS"
MainReport = New AGS_WEB_ORDER
Case "BK"
MainReport = New BK_WEB_ORDER
Case "OTHER"
MainReport = New OTHER_WEB_ORDER
End Select
End Set

End Property
Public Property SetEmail() As String
'<PARA>
' This property is the first property that must be called from the
Order.aspx page as it is the one that is used to define
'the email address to use for the email address
'</PARA>
'<VALUE>
'm*@here.com
'</VALUE>
Get
SetEmail = M_EmailAddress
End Get
Set(ByVal Value As String)
M_EmailAddress = Value
End Set

End Property
Public Property SetOrderNumber() As String
'<PARA>
'Pass this the order number
'</PARA>
'<VALUE>
'OrderNumber
'</VALUE>
Get
SetOrderNumber = M_OrderNumber
End Get
Set(ByVal Value As String)
M_OrderNumber = Value
End Set

End Property
Public ReadOnly Property Report() As ReportDocument
'<PARA>
'This passeds the report back to Order.aspx
'</PARA>
'
Get
Report = MainReport
End Get
End Property

Private Sub ReadRegistry()
Dim ParentKey As RegistryKey = Registry.LocalMachine
Dim SubKey As String = "SOFTWARE\KHAOS_PDF_EXPORT"
Dim Key As RegistryKey

Try
'Open the registry key.
Key = ParentKey.OpenSubKey(SubKey, True)
If Key Is Nothing Then 'if the key doesn't exist
Throw New Exception("The registry key doesn't exist")
End If

'Get the value.
szErrorMailPrimary = CType(Key.GetValue("MainErrorMail"), String)
szErrorMailSecondary = CType(Key.GetValue("SecondErrorMail"),
String)
szMailServer = CType(Key.GetValue("MailServerIPAddress"), String)
szMailFrom = CType(Key.GetValue("MailFromAddress"), String)
szPathToPDF = CType(Key.GetValue("PathToPDF"), String)
szPathToExport = CType(Key.GetValue("PathToExport"), String)
szKhaosConnectionString =
CType(Key.GetValue("ConnectionString"), String)
szAGSConnectionString =
CType(Key.GetValue("AGSConnectionString"), String)
szServer = CType(Key.GetValue("Server"), String)
szDatabase = CType(Key.GetValue("DB"), String)
szUserName = CType(Key.GetValue("User"), String)
szPassword = CType(Key.GetValue("Password"), String)
Catch e As Exception
'EventLog.CreateEventSource("KhaosXML", "Unable to Pen Khaos
Registry Settings. The following error occured " & e.Message,
EventLogEntryType.Error,1970)
MsgBox(e.Message)
'TODO Put proper error trapping in
End Try
End Sub

Private Sub ErrorMail()
'This is the function that sends an email to the relevant people in
the event of a failure
Try
Dim sysMessage As New MailMessage
sysMessage.From = szMailFrom
sysMessage.To = szErrorMailPrimary
sysMessage.Cc = szErrorMailSecondary
sysMessage.Subject = "WARNING WARNING - ERROR WITH WEB ORDER"
Dim szBody As String
szBody = szBody & "There has been a problem recorder in the
evvent log of the database server." & vbCrLf
szBody = szBody & "This event log warning will tell you what has
gone wrong and where." & vbCrLf
szBody = szBody & "Please inform an administrator as soon as
possible please." & vbCrLf & vbCrLf
sysMessage.Body = szBody
SmtpMail.SmtpServer = szMailServer
SmtpMail.Send(sysMessage)
Catch ex As Exception
EventLog.WriteEntry("KhaosXML", "Unable to email PDF. The
following error occurred " & ex.Message, EventLogEntryType.Error, 1970)
Exit Sub
End Try
End Sub

Function EmailPDF() As ReportDocument

'This creates the fucntion that emails the PDF to the customer

Dim exportFilePath As String
Dim oguid As Guid
Dim szFileName As String = oguid.NewGuid.ToString
Dim crTable As CrystalDecisions.CrystalReports.Engine.Table
Dim iCount As Integer

Try

MainReport = ChangeLogOnInfo(MainReport, "HERA", "reporter",
"reporter")

'OK We know set the parameters required by the report

Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
crParameterFieldDefinitions =
MainReport.DataDefinition.ParameterFields

crParameterFieldLocation =
crParameterFieldDefinitions.Item("OrderNumber")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New
CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = M_OrderNumber
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crPara meterValues)

MainReport = ChangeLogOnInfo(MainReport, "HERA", "reporter",
"reporter")

'MainReport.PrintToPrinter(1, False, 1, 1)
'Try
' Dim sysMessage As New MailMessage
' sysMessage.From = szMailFrom
' sysMessage.To = M_EmailAddress
' sysMessage.Subject = "Confirmation of Order at The Adult Gift
Shop Limited"
' Dim szBody As String
' szBody = szBody & "We enlose a PDF version of your order for
your records." & vbCrLf
' szBody = szBody & "If you do not have adobe acrobat reader
installed please click on the link below to install it" & vbCrLf
' szBody = szBody &
"http://www.adobe.com/products/acrobat/readstep2.html" & vbCrLf & vbCrLf
' szBody = szBody & "Please do not reply to this email address
all emails. Should be addressed to en*****@theadultgiftshop.com" & vbCrLf
' szBody = szBody & vbCrLf & vbCrLf & "Thankyou for shopping at
the Adult Gift Shop"
' sysMessage.Body = szBody
' Dim sysAttachment As MailAttachment = New
MailAttachment(exportFilePath, MailEncoding.Base64)
' sysMessage.Attachments.Add(sysAttachment)
' SmtpMail.SmtpServer = szMailServer
' SmtpMail.Send(sysMessage)

' If IO.File.Exists(exportFilePath) Then
' IO.File.Delete(exportFilePath)
' End If

'Catch ex As Exception
' EventLog.WriteEntry("KhaosXML", "Unable to email PDF. The
following error occurred " & ex.Message & "Order Number " & M_OrderNumber & "
Email Address " & M_EmailAddress & ".", EventLogEntryType.Error, 1970)
' ErrorMail()
' Exit Function
'End Try

Catch ex As Exception
MsgBox(ex.Message)
End Try
Return MainReport

End Function
Private Function ChangeLogOnInfo(ByVal Report As ReportDocument, ByVal
ServerName As String, ByVal UserName As String, ByVal Password As String) As
ReportDocument
Dim crConnectionInfo As New ConnectionInfo
With crConnectionInfo
.ServerName = ServerName

.UserID = UserName
.Password = Password
End With

Dim crTable As Table
Dim LogOnInfo As TableLogOnInfo
For Each crTable In Report.Database.Tables
LogOnInfo = crTable.LogOnInfo
'Debug.Write(crTable.Name)
''OK If I get this right we dont need to chnage database names
but will need to chnage servers and usernames and passwords as we
'' may have subreports pointing to different areas

'LogOnInfo.ConnectionInfo.DatabaseName = Database

LogOnInfo.ConnectionInfo.ServerName = ServerName
LogOnInfo.ConnectionInfo.UserID = UserName
LogOnInfo.ConnectionInfo.Password = Password
'LogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(LogOnInfo)
Next
'OK AND NOW WE DO THE SUB REPORTS
Dim crReportObject As ReportObject
Dim crReportObjects As ReportObjects
Dim crSection As Section
Dim crSections As Sections
Dim SubReportObject As SubreportObject
Dim subReportDocument As ReportDocument
Dim crSubTable As Table
Dim crSubTables As Tables
Dim crSubLogOnInfo As TableLogOnInfo
crSections = Report.ReportDefinition.Sections

For Each crSection In crSections
crReportObjects = crSection.ReportObjects

For Each crReportObject In crReportObjects

If TypeOf crReportObject Is SubreportObject Then
SubReportObject = CType(crReportObject, SubreportObject)
subReportDocument =
SubReportObject.OpenSubreport(SubReportObject.Subr eportName)

crSubTables = subReportDocument.Database.Tables

For Each crSubTable In crSubTables
crSubLogOnInfo = crSubTable.LogOnInfo
crSubLogOnInfo = crTable.LogOnInfo
crSubLogOnInfo.ConnectionInfo.ServerName = ServerName
crSubLogOnInfo.ConnectionInfo.UserID = UserName
crSubLogOnInfo.ConnectionInfo.Password = Password
crSubTable.ApplyLogOnInfo(LogOnInfo)
Next
End If
Next
Next

Return Report

End Function
End Class

Nov 18 '05 #5
Hi Alixx:

Unfortunately I'm not real familiar with Crystal. I struggled quite a
bit with it once just getting it properly registered (licensed) to run
when we upgraded from .net 1.0 to 1.1. I think I had to sacrifice 3
virgin purple chickens that night under a full moon.

The Crystal team runs a blog:
http://blogs.aspadvice.com/crystal/

Perhaps you could mail someone there fromt the contact link and get a
reasonable response!

--
Scott
http://www.OdeToCode.com/

On Wed, 6 Oct 2004 07:55:11 -0700, "Alixx Skevington"
<Al*************@discussions.microsoft.com> wrote:
Scott,

OK; I have trawled the Net for possible solutions to this problem; I have
tried altering Machine.config. to make the aspne_wp.exe run as a Newtork user
rather than a local Machine user Nada. I have made the website run as a user
that is added to the sqlserver as a authorised user and is even given dbo
rights to the SQL Server. I am at the point of even contemplating sacrificing
a virgin blue chicken on a clear moonlit night to see if this will help.
Surely to god it should not be this difficult to renew logon info for this
seeing as it is dersigned to do it.

I am running SQL Server 2000 in a Windows 2000 AD Domain


Nov 18 '05 #6
Thanks Scott for the link I will do; it's like everything else I have found
with .Net is when it works DONT UPGRADE anything, I have just had two
websites go down because I upgrdaded my dev machine to xp service pack 2 but
didn't upgrade the webserver to .net framework sp1

aaaaaaargh

Cheers I will keep you informed as I find things out

Alixx

"Scott Allen" wrote:
Hi Alixx:

Unfortunately I'm not real familiar with Crystal. I struggled quite a
bit with it once just getting it properly registered (licensed) to run
when we upgraded from .net 1.0 to 1.1. I think I had to sacrifice 3
virgin purple chickens that night under a full moon.

The Crystal team runs a blog:
http://blogs.aspadvice.com/crystal/

Perhaps you could mail someone there fromt the contact link and get a
reasonable response!

--
Scott
http://www.OdeToCode.com/

On Wed, 6 Oct 2004 07:55:11 -0700, "Alixx Skevington"
<Al*************@discussions.microsoft.com> wrote:
Scott,

OK; I have trawled the Net for possible solutions to this problem; I have
tried altering Machine.config. to make the aspne_wp.exe run as a Newtork user
rather than a local Machine user Nada. I have made the website run as a user
that is added to the sqlserver as a authorised user and is even given dbo
rights to the SQL Server. I am at the point of even contemplating sacrificing
a virgin blue chicken on a clear moonlit night to see if this will help.
Surely to god it should not be this difficult to renew logon info for this
seeing as it is dersigned to do it.

I am running SQL Server 2000 in a Windows 2000 AD Domain


Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gidrazas | last post by:
Hi all. I want to get data from Sybase ASA9 to report named Subjektai.rpt in web form. I made ODBC connection to DB and it looks OK. But whe i run project i get an error like this. Logon...
1
by: James | last post by:
Hello group: I guessing there is no way to create an OLEDB linked table in Access to SQL Server, am I correct? Basically, I've currently migrated one of my Access database tables to SQL Server,...
1
by: Manfred | last post by:
I want to access via CDO outlook. Therfore i have to logon. In VB.NEt I make it like: Dim objSession As MAPI.Session If objSession Is Nothing Then objSession = CreateObject("MAPI.Session")...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
2
by: GFro | last post by:
I am getting the following error since we upgraded from .NET Framework 1.0 to 1.1. The reports all ran fine yesterday. I get this error in all apps with reports. The apps run fine but the...
3
by: Milan Todorovic | last post by:
Hello, I need help. I have experience in ASP.NET programming, but this is my first dealing with Crystal Reports. I'm trying to make the most basic report purely for testing purposes: connect to...
10
by: et | last post by:
I have an asp.net program that uses a connection string, using integrated security to connect to a sql database. It runs fine on one server, but the other server gives me the error that "Login...
2
by: J-T | last post by:
Hi All, We have an asp.net application on a windows 2003 server which is part of a domain controller which my worksatis is too. We have impersonated in our applciation with a fixed identity...
0
by: Marty Cruise | last post by:
I successfully deploy my application to 20 domain users. Only one new user is giving me a problem, although he can access all domain resources. When he clicks the installation link on the...
0
by: robpimentel | last post by:
Hi, I've been using DB2 for about 1 week, so please bear with me. DB2 Connect Enterprise Edition v8.1 FixPack 5 Windows Server 2003 Standard Edition SP1 Here is an error that continues to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.