What I'm trying to do: change the filepath of an xsd connection in a RPT file, then save that out to a new file.
string keyLogon = "QE_LogonProperties";
string keyServerDescription = "QE_ServerDescription";
if (rpt.DataSourceConnections[0].Attributes.Collection.ContainsKey(keyLogon))
{
NameValuePair2 logon = rpt.DataSourceConnections[0].Attributes.Collection.LookupNameValuePair(keyLogon);
DbConnectionAttributes xsdConn = logon.Value as DbConnectionAttributes;
NameValuePair2 filePath = xsdConn.Collection[0] as NameValuePair2;
Debug.WriteLine("Current Connection {0}".FormatString(filePath.Value.ToString()));
filePath.Value = @"
HOLYCRAPTHISISTHEWRONGSERVER\Schemas\0001.xsd";
Debug.WriteLine("New Connection ".FormatString(filePath.Value));
}
if (rpt.DataSourceConnections[0].Attributes.Collection.ContainsKey(keyServerDescription))
{
NameValuePair2 serverDescription = rpt.DataSourceConnections[0].Attributes.Collection.LookupNameValuePair(keyServerDescription);
serverDescription.Value = serverDescription.Value + "BLAH";
}
So far so good. However, when I then save the file, the data that I explicitly set is gone. I can't use SetDataSourceConnection or SetLogon because those both want to work with database connections. In my situation I'm passing in a DataSet that matches the XSD.
One caveat: the xsd file may or may not exist at the specified path when I set it. I'm eventually deploying these to Production, but I can't deploy the Xsd to Prod before the report is done.
Question is this: how can I change the path to the xsd, save the file to a new place and have the new file point to the new xsd? I am able to set the SummaryInfo.ReportTitle and save it, then see the new file with the new ReportTitle. So I must be doing something wrong when setting the connection.
Edited by: jwcollum on Jan 28, 2010 10:40 PM