Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Getting rid of Crystal Reports Authentication?? Post Reply Post New Topic
Author Message
vineet
Newbie
Newbie


Joined: 25 Nov 2007
Location: United Arab Emirates
Online Status: Offline
Posts: 1
Quote vineet Replybullet Topic: Getting rid of Crystal Reports Authentication??
    Posted: 25 Nov 2007 at 10:52pm
Hi friends,
I am facing a problem when i am connecting my front end Visual Basic with Crystal Reports X1....everything is working fine...but even though i have given my Data source name,User iD and password... for connecting to the database...while running i still get the Authenticating message to give the userid and password for the crystal reports to connect to the databas.....i do not want to get this message.

please see through my code below....
====================================
Dim lstrsql As String
lstrsql = "select a.first_name,a.middle_name,a.last_name,a.employee_code,a.email_id,b.NET_SALARY from employeemaster a,payhistory b where a.DEPARTMENT_CODE=" & Trim(cboDepartment.Columns("departmentcode").Text) & " and a.bm_cd=" & GSTR_LOGINLOC & " and a.emp_active=-1 and b.PAY_MONTH='" & Trim(cboMonth.Columns(1).Text) & "' and b.PAY_YEAR='" & txtYear.Text & "' and a.EMPLOYEE_CODE=b.EMPLOYEE_CODE"
Set rslc = osqlhandlr.GetRs(lstrsql, 1)
If rslc.RowCount > 0 Then
Set rpt = rdApp.OpenReport(App.Path + "\reports\PaySlipEmail.rpt")
rpt.ExportOptions.ODBCDataSourceName = "ALZ"
rpt.ExportOptions.ODBCDataSourcePassword = "ALZ"
rpt.ExportOptions.ODBCDataSourceUserID = "ALZ"

Dim crParamDefs As ParameterFieldDefinitions
Dim crParamDef As ParameterFieldDefinition
Set crParamDefs = rpt.ParameterFields
With rpt
While Not rslc.EOF
For Each crParamDef In crParamDefs
With crParamDef
Select Case .ParameterFieldName
'this is the Stored Procedure Parameter
Case "PAYMONTH"
.SetCurrentValue Month("01" & "/" & cboMonth.Columns(1).Text & "/" & Trim(txtYear.Text))
Case "PAYYEAR"
.SetCurrentValue Year("01" & "/" & cboMonth.Columns(1).Text & "/" & Trim(txtYear.Text))
Case "LOCATIONCODE"
.SetCurrentValue Trim(GSTR_LOGINLOC)
Case "employee_code"
.SetCurrentValue Trim(rslc!EMPLOYEE_CODE)
Case Else 'etc.
End Select
End With
Next
.ExportOptions.FormatType = crEFTPortableDocFormat
.ExportOptions.DestinationType = crEDTEMailMAPI
'.ExportOptions.DiskFileName = App.Path & "\" & rslc!first_name & " " & rslc!middle_name & " " & rslc!last_name & ".pdf"
'.ExportOptions
'.ExportOptions.PDFExportAllPages = True
.ExportOptions.PDFExportAllPages = .ExportOptions.PDFExportAllPages
.ExportOptions.PDFFirstPageNumber = .ExportOptions.PDFFirstPageNumber
.ExportOptions.PDFLastPageNumber = .ExportOptions.PDFLastPageNumber
.ExportOptions.MailSubject = rslc!FIRST_NAME & " " & rslc!MIDDLE_NAME & " " & rslc!LAST_NAME
.ExportOptions.MailMessage = "Please Find the attachment for" & " " & Format("01" & "/" & cboMonth.Columns(1).Text & "/" & Trim(txtYear.Text), "mmm") & " Month Pay Slip"
.ExportOptions.MailToList = "it.prog1@alzahra.com"
'.ExportOptions.MailToList = rslc!email_id
.Export (False)
rslc.movenext
Wend
End With
End If
MsgBox "Done"
Me.MousePointer = vbNormal
End Sub


Please Help ME!!!!!!!!!!!!!!!!!!!
IP IP Logged
wattsjr
Groupie
Groupie
Avatar

Joined: 25 Jun 2007
Location: United States
Online Status: Offline
Posts: 51
Quote wattsjr Replybullet Posted: 26 Nov 2007 at 10:38am
Hi vineet,
 
You don't specify which version of VB you're using, but I'm guessing that it's either the 2003 or 2005 .NET version.
 
Unlike earlier versions of VB, yoiu have to log in to each table used in the report. Brian Bischof gives a nice explanation in his book "Crystal Reports .NET Programming" in chapter 17 and includes a coding example (17-11). see Logging On with the ReportDocument object.
 
If you can't get ahold of a copy of the book (and it's worth gettting) try what I've added below.
 
Here is an example that I used in one of my apps.
' Set the ConnectionInfo properties for logging on to the Database
' If you are using ODBC, this should be the DSN name NOT the physical server name.
' If you are NOT using ODBC, this should be the physical server name
'
With crConnectionInfo
    .ServerName = SrvName
    ' If you are connecting to Oracle there is no DatabaseName. Use an empty string.
    .DatabaseName = ""
    .UserID = LogonID
    .Password = Password
End With
'
' This code works for both user tables and stored
' procedures. Set the CrTables to the Tables collection of the report
CrTables = crReportDocument.Database.Tables
' Loop through each table in the report and apply the LogonInfo information'
For Each CrTable In CrTables
    crtableLogoninfo = CrTable.LogOnInfo
    crtableLogoninfo.ConnectionInfo = crConnectionInfo
    CrTable.ApplyLogOnInfo(crtableLogoninfo)
    If Not CrTable.TestConnectivity() Then
        MsgBox("Invalid Credentials for Table: " & CrTable.Name & ".Table    Login Failed")
    End If
Next
-jrw
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.012 seconds.