display database details in crystal report in asp.net using sql serve

Posted by Dn2010 under ASP.NET on 1/6/2011 | Points: 10 | Views : 4931 | Status : [Member] | Replies : 7
hi friends,

how to display database details in crystal report in asp.net using sql server.

please give the behind the code.

thanks.




Responses

Posted by: Karthikanbarasan on: 1/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

This article shows the step by step process of using the crystal report and get datas from SQL db and show in crystal reports.

http://www.dotnetking.com/ArticleDetails.aspx?ArticleID=44

Thanks
Karthik
www.f5Debug.net

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dn2010 on: 1/6/2011 [Member] Starter | Points: 25

Up
0
Down
thanks for your response,

but,
please give the any other samples.

thanks.

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Are you looking for any specific code sample? The link which i sent has the step by step process...

Let me know in case of any specific sample required so that i can get u

Thanks
Karthik

Thanks
Karthik
www.f5Debug.net

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dn2010 on: 1/6/2011 [Member] Starter | Points: 25

Up
0
Down
yes, i want to behind the code for it.

thanks.

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Ok... Let me know which language you want C# or VB.net... ill write code and publish here...

Thanks
Karthik
www.f5Debug.net

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dn2010 on: 1/6/2011 [Member] Starter | Points: 25

Up
0
Down
yes,i want to Asp.net with C# using sqlserver.

thanks.

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/6/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Try this code

protected void Page_Load(object sender, EventArgs e)

{

// this.CrystalReportSource1.ReportDocument.Load(@"C:\Report.rpt");
ReportDocument doc = new ReportDocument();
doc.Load(@"C:\Report.rpt");


//2) Once I have the data I need to apply it to the connection of the report
ConnectionInfo crConnection = new ConnectionInfo();
crConnection.UserID = "username";
crConnection.ServerName = "serverName";
crConnection.DatabaseName = "";
crConnection.Password = "password";


AssignConnectionInfo(doc, crConnection);

doc.SetDatabaseLogon(crConnection.UserID, crConnection.Password, crConnection.ServerName, crConnection.DatabaseName);


CrystalReportViewer1.ReportSource = doc;
CrystalReportViewer1.RefreshReport();


}


private void AssignConnectionInfo(ReportDocument document, ConnectionInfo crConnection)
{
foreach (CrystalDecisions.CrystalReports.Engine.Table table in document.Database.Tables)
{
TableLogOnInfo logOnInfo = table.LogOnInfo;
if (logOnInfo != null)
{
table.ApplyLogOnInfo(table.LogOnInfo);
table.LogOnInfo.TableName = table.Name;
table.LogOnInfo.ConnectionInfo.UserID = crConnection.UserID;
table.LogOnInfo.ConnectionInfo.Password = crConnection.Password;
table.LogOnInfo.ConnectionInfo.DatabaseName = crConnection.DatabaseName;
table.LogOnInfo.ConnectionInfo.ServerName = crConnection.ServerName;

}
}



}


Thanks
Karthik
www.f5Debug.net

Dn2010, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response