How to code loginID & password for Crystal report

  • Thread starter Thread starter Bill Nguyen
  • Start date Start date
B

Bill Nguyen

I'm using ODBC DSN to create CR reports. The VP app keeps popping up login
dialog to ask for userID & password. I would like to be able to supply the
DSN id & password in VB.NET app instead. Any suggestion is greatly
appreciated.
Thanks
Bill
 
Bill

My first suggestion is to ditch ODBC. The drawbacks of it far outweight the benefits. I recommend using either JET or OLEDB drivers to connect directly to your database. I don't know exactly what type of database you are using, so I will post for both Access and SQL Server. For Access databases, use JET 4.0 drivers. In the code, connect to your database like so

Dim oRpt As MyRepor
Dim oInfo As CrystalDecisions.Shared.TableLogOnInfo 'you must use a seperate variabl
Dim i As Intege

oRpt = New MyRepor
For i = 0 To oRpt.Database.Tables.Count -
oInfo = oRpt.Database.Tables(i).LogOnInf
oInfo.ConnectionInfo.ServerName = strPathToAccessMDBFil
oInfo.ConnectionInfo.UserID = "Admin
oInfo.ConnectionInfo.Password = "
oRpt.Database.Tables(i).ApplyLogOnInfo(oInfo
Nex

For SQL Server do something like this
oRpt = New EstimateSummar
For i = 0 To oRpt.Database.Tables.Count -
oInfo = oRpt.Database.Tables(i).LogOnInf
oInfo.ConnectionInfo.DatabaseName = strMyDbNam
oInfo.ConnectionInfo.Password = "
oInfo.ConnectionInfo.UserID = "
oInfo.ConnectionInfo.ServerName = strSQLServerNam
oRpt.Database.Tables(i).ApplyLogOnInfo(oInfo
Nex

'apply the login information to all the table
oRpt.SetDatabaseLogon(strUser, strPassword, strSQLServerName, strMyDbName

I hope this helps you fix your problem

Jason
 
Hello,

Private Sub MenuItemchartofaccount_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MenuItemchartofaccount.Click

Dim path As CRchartofaccount
path = New CRchartofaccount()
CrystalReportViewer1.ReportSource = path
CrystalReportViewer1.connect=moduleconnection.connection
CrystalReportViewer1.SetDatabaseLogin("DBNAme","uiD","PWD")
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Show()
End Sub


Thanks,


Warm Regards,

Ayaz Ahmed
Software Engineer & Web Developer
Creative Chaos (Pvt.) Ltd.
"Managing Your Digital Risk"
http://www.csquareonline.com
Karachi, Pakistan
Mobile +92 300 2280950
Office +92 21 455 2414
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top