Reputation: 11
I have change connection string at run time but it not picking the record from new connection string. Code is:
private void Report_Load(object sender, EventArgs e)
{
try
{
foreach (ConnectionInfo item in Tests1.DataSourceConnections)
{
item.SetConnection(@".\sqlexpress", @"C:\DBFile\fff2011.mdf", true);
}
crystalReportViewer1.ReportSource = Tests1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Upvotes: 1
Views: 621
Reputation: 112
I have used ODBC as the datasource in the report to do this. That way you don't have to change the report or anything in code when going between live and test.
Upvotes: 1