crystalReportViewer in windows application
i'm using a code to send the ConnectionInfo to the crystalReportViewer
private void button1_Click(object sender, EventArgs e)
{
ConnectionInfo myConnectionInfo = new ConnectionInfo();
myConnectionInfo.ServerName = "192.168.3.58";
myConnectionInfo.DatabaseName = "SHRK-Traffic";
myConnectionInfo.UserID = "sa";
myConnectionInfo.Password = "pass";
setDBLOGONforREPORT(myConnectionInfo);
crystalReportViewer1.Visible = true;
}
private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
{
TableLogOnInfos mytableloginfos = new TableLogOnInfos();
mytableloginfos = crystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
{
myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
开发者_JAVA百科 }
}
i'm working with this code in web app and it's working fine..but in windows app it show that error
i'm getting an error
You need to create a TableLogOnInfo object, then set it's ConnectionInfo object to the correct information i.e.:
TableLogOnInfo loginDetails = new TableLogOnInfo();
loginDetails.ConnectionInfo.ServerName = "ALFA1\\ACMSDB";
loginDetails.ConnectionInfo.UserID = "***";
loginDetails.ConnectionInfo.Password = "***";
loginDetails.ConnectionInfo.DatabaseName = "database";
loginDetails.ConnectionInfo.IntegratedSecurity = false;
Then go ahead and add that configured TableLogOnInfo object to your LogOnInfo collection:
crystalReportViewer1.LogOnInfo.Add(loginDetails);
精彩评论