VB.NET - Vb.net 2008 Crystal Report Connection to SQL 2008

Asked By Ben Sebuabe on 11-Jun-13 08:38 AM
Hi to All.

Please, I'm using Vb.net 2008 and sql 2008 and I have  a crystal report to print, but the connection to the sql 2008 programmatically becomes a problem. Can some show me the connection code through the crystal report to the sql database. Thanks. Ben
Robbe Morris replied to Ben Sebuabe on 11-Jun-13 10:27 AM
I don't work a lot in Crystal Reports. So, I can't tell you whether this is best practice or not. But, it does work.

private void AddDataBaseInformation(ReportDocument rpt)
  foreach (CrystalDecisions.CrystalReports.Engine.Table table in rpt.Database.Tables)
    var credentials = table.LogOnInfo;
    credentials.ConnectionInfo.ServerName = "server name"
    credentials.ConnectionInfo.DatabaseName = "database name ";
    credentials.ConnectionInfo.UserID = "sql user";
    credentials.ConnectionInfo.Password = "sql pwd";
    credentials.ConnectionInfo.IntegratedSecurity = false;
Ben Sebuabe replied to Robbe Morris on 11-Jun-13 10:48 AM
Thank you Mr. Robbe so much for your response.

Please, I'm using VB.NET 2008 and it seems your code is in c#. If you could change that in vb.net for me, I'd be glad. Ben