Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have 3 databases connected to my crystal report, it is working in my crystal report. Now I want to view it in ASP.Net but it says Database login failed.

What I have tried:

'FOR LOGIN CREDENTIALS
With crConnectionInfo
    .ServerName = server
    .DatabaseName = dbname
    .UserID = userid
    .Password = "pw
End With

With crConnectionInfo1
    .ServerName = server
    .DatabaseName = dbname
    .UserID = userid
    .Password = "pw
End With

With crConnectionInfo2
    .ServerName = server
    .DatabaseName = dbname
    .UserID = userid
    .Password = "pw
End With

CrTables = reportdoc.Database.Tables

Dim myTable1 As CrystalDecisions.CrystalReports.Engine.Table = CrTables(0)
Dim myTable2 As CrystalDecisions.CrystalReports.Engine.Table = CrTables(1)
Dim myTable3 As CrystalDecisions.CrystalReports.Engine.Table = CrTables(2)

Dim myTableLogonInfo As TableLogOnInfo = myTable1.LogOnInfo
Dim myTableLogonInfo1 As TableLogOnInfo = myTable2.LogOnInfo
Dim myTableLogonInfo2 As TableLogOnInfo = myTable3.LogOnInfo

crtableLogoninfo.ConnectionInfo = crConnectionInfo
myTable1.ApplyLogOnInfo(myTableLogonInfo)


crtableLogoninfo.ConnectionInfo = crConnectionInfo1
myTable2.ApplyLogOnInfo(myTableLogonInfo1)


crtableLogoninfo.ConnectionInfo = crConnectionInfo2
myTable3.ApplyLogOnInfo(myTableLogonInfo2)


but this still throw database login failed.
Posted
Updated 6-Nov-17 4:43am

1 solution

Read through your code:
VB.NET
Dim myTableLogonInfo As TableLogOnInfo = myTable1.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
myTable1.ApplyLogOnInfo(myTableLogonInfo)

  1. Get myTable1.LogOnInfo, and store it in myTableLogonInfo;
  2. Change the completely unrelated variable crtableLogoninfo;
  3. Apply the unchanged logon info from myTableLogonInfo to myTable1;

Presumably, the three lines that start crtableLogoninfo.ConnectionInfo = ... should be referencing the myTableLogonInfo... variables instead.
VB.NET
Dim myTableLogonInfo As TableLogOnInfo = myTable1.LogOnInfo
myTableLogonInfo.ConnectionInfo = crConnectionInfo
myTable1.ApplyLogOnInfo(myTableLogonInfo)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900