How to code loginID & password for Crystal report

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Nguyen

    How to code loginID & password for Crystal report

    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


  • Jason F

    #2
    RE: How to code loginID & password for Crystal report

    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 CrystalDecision s.Shared.TableL ogOnInfo 'you must use a seperate variabl
    Dim i As Intege

    oRpt = New MyRepor
    For i = 0 To oRpt.Database.T ables.Count -
    oInfo = oRpt.Database.T ables(i).LogOnI nf
    oInfo.Connectio nInfo.ServerNam e = strPathToAccess MDBFil
    oInfo.Connectio nInfo.UserID = "Admin
    oInfo.Connectio nInfo.Password = "
    oRpt.Database.T ables(i).ApplyL ogOnInfo(oInfo
    Nex

    For SQL Server do something like this
    oRpt = New EstimateSummar
    For i = 0 To oRpt.Database.T ables.Count -
    oInfo = oRpt.Database.T ables(i).LogOnI nf
    oInfo.Connectio nInfo.DatabaseN ame = strMyDbNam
    oInfo.Connectio nInfo.Password = "
    oInfo.Connectio nInfo.UserID = "
    oInfo.Connectio nInfo.ServerNam e = strSQLServerNam
    oRpt.Database.T ables(i).ApplyL ogOnInfo(oInfo
    Nex

    'apply the login information to all the table
    oRpt.SetDatabas eLogon(strUser, strPassword, strSQLServerNam e, strMyDbName

    I hope this helps you fix your problem

    Jason

    Comment

    Working...