Show Database Login Window when run Crystal Report in vb.net

mukesh

Member
Joined
Jun 22, 2005
Messages
11
Programming Experience
1-3
I develop a application in vb.net with some Crystal Report. When I copy this application into another computer with source code then at running the crystal Report show a Window Form for Database Login. There are some fields for ServerName, DatabaseName, Login, Password.

I don't know abt this problem and I am not able to solve this problem. So, if anybody knows about that pls, tell me.

Thanks in Advance.
 
if you are getting the database login prompt then you are not correctly logging onto the report within your application code

here is an example of the code we use to logon to a report
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] obj_Report [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] CrystalDecisions.CrystalReports.Engine.ReportDocument
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] frm_Viewer [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] frmViewReport
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] crTableLogonInfo [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] TableLogOnInfo
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] crConnectionInfo [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ConnectionInfo
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] crTable [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] CrystalDecisions.CrystalReports.Engine.Table
 
[SIZE=2]
crTableLogonInfo = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] TableLogOnInfo
crConnectionInfo = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ConnectionInfo
 
crConnectionInfo.DatabaseName = g_str_Database
crConnectionInfo.ServerName = g_str_Server
crConnectionInfo.UserID = g_str_Username
crConnectionInfo.Password = g_str_Password
 
crTableLogonInfo.ConnectionInfo = crConnectionInfo
[/SIZE][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][SIZE=2] obj_Report
 
.Load(m_str_ReportFilename)
 
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] crTable [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] .Database.Tables
crTable.ApplyLogOnInfo(crTableLogonInfo)
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2]crTable.Location = g_str_Database & ".dbo." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)[SIZE=2]
.SetDatabaseLogon(g_str_Username, g_str_Password, g_str_Server, g_str_Database)
 
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]With
 
[SIZE=2]
[COLOR=black]frm_Viewer.crv_ReportViewer.ReportSource = obj_Report
frm_Viewer.ShowDialog()
[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE][/SIZE]

also, if your report has subreports then you also need to logon to each of these


HTH,
Craig



 
Last edited by a moderator:
Back
Top