Something wrong when changing the ConnectionString ?
Posted: Fri Jul 17, 2009 1:34 pm
Hello together
following short question about changing the connection string on a report:
The goal to achive is to give a connection-string from the application to all database objects in the dictionary. This should give the ability to design a report independent from given datasources in the application and simply create them in the report properly and then, when loading the report in the application to establish a data-connection with the right parameter (user, password, database and so on) directly.
For this i wrote some little lines of code which redeclares all database entries in the dictionary with new database items with a new connection string.
This looks like that:
string LocationReport = Application.StartupPath + @"\report\" + this.sPrintReport;
string[] theDatabases = null;
if (this.lCheckIfReportExists()) {
this.oReport.Load(LocationReport);
theDatabases = new string[this.oReport.Dictionary.Databases.Count];
for(int i = 0; i < this.oReport.Dictionary.Databases.Count; i++) {
theDatabases = this.oReport.Dictionary.Databases.Name;
}
this.oReport.Dictionary.Databases.Clear();
for(int i = 0; i < theDatabases.Length; i++) {
this.oReport.Dictionary.Databases.Add(new StiSqlDatabase(theDatabases,this.oConn.DBConnectionString));
}
this.oReport.Render(true);
this.oReport.Print(true);
} else {
MessageBox.Show("Der Report unter \""+LocationReport+"\" konnte nicht geladen werden.","Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error);
}
As you see, new StiSQLDatabases are created through the DBConnectionString of my application.
This always produces the error (sorry, it's in german: "System.ArgumentException: Schlusselwort wird nicht unterstutzt: 'provider'.", which must sound in english like keyword is not supported "provider").
After this, i tried to replace the Connection string with a hard coded value which i copy&pasted from the Report-Designer where you could build new connections to simply get it working, this looks like:
for(int i = 0; i < theDatabases.Length; i++) {
this.oReport.Dictionary.Databases.Add(new StiSqlDatabase(theDatabases,@"Provider=SQLOLEDB.1;Password=xxx;Persist Security Info=True;User ID=xxx;Initial Catalog=OXStundenzettel;Data Source=w2ka"));
}
This brings up the same error (System.ArgumentException: Schlusselwort wird nicht unterstutzt: 'provider'. / keyword is not supported 'provider').
As far as i can see, this is a valid connection string. Someone any idea what's the problem here ?
(maybe this helps, here's the callstack up to my method:
System.ArgumentException: Schlusselwort wird nicht unterstutzt: 'provider'.
bei System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
bei System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
bei System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
bei System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
bei System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
bei System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value)
bei System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
bei System.Data.SqlClient.SqlConnection..ctor(String connectionString)
bei Stimulsoft.Report.Dictionary.StiSqlAdapterService.CreateConnectionInDataStore(StiDictionary dictionary, StiSqlDatabase database)
bei Stimulsoft.Report.Dictionary.StiSqlDatabase.RegData(StiDictionary dictionary, Boolean loadData)
bei Stimulsoft.Report.Dictionary.StiDictionary.CreateDatabases(Boolean loadData)
bei Stimulsoft.Report.Dictionary.StiDictionary.Connect(Boolean loadData)
bei Stimulsoft.Report.Engine.StiRenderProviderV2.ConnectToData(StiReport report)
bei Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
bei Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
bei Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
bei Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
bei Stimulsoft.Report.StiReport.Render(Boolean showProgress)
bei OXStundenzettel.AFDPWindow.PrintPreview() in d:\AFSourcen\OXStundenzettel\AFDPWindow.cs:Zeile 87.
)
Thanks a lot for any reply!
With greetings from germany
Andre
following short question about changing the connection string on a report:
The goal to achive is to give a connection-string from the application to all database objects in the dictionary. This should give the ability to design a report independent from given datasources in the application and simply create them in the report properly and then, when loading the report in the application to establish a data-connection with the right parameter (user, password, database and so on) directly.
For this i wrote some little lines of code which redeclares all database entries in the dictionary with new database items with a new connection string.
This looks like that:
string LocationReport = Application.StartupPath + @"\report\" + this.sPrintReport;
string[] theDatabases = null;
if (this.lCheckIfReportExists()) {
this.oReport.Load(LocationReport);
theDatabases = new string[this.oReport.Dictionary.Databases.Count];
for(int i = 0; i < this.oReport.Dictionary.Databases.Count; i++) {
theDatabases = this.oReport.Dictionary.Databases.Name;
}
this.oReport.Dictionary.Databases.Clear();
for(int i = 0; i < theDatabases.Length; i++) {
this.oReport.Dictionary.Databases.Add(new StiSqlDatabase(theDatabases,this.oConn.DBConnectionString));
}
this.oReport.Render(true);
this.oReport.Print(true);
} else {
MessageBox.Show("Der Report unter \""+LocationReport+"\" konnte nicht geladen werden.","Fehler", MessageBoxButtons.OK,MessageBoxIcon.Error);
}
As you see, new StiSQLDatabases are created through the DBConnectionString of my application.
This always produces the error (sorry, it's in german: "System.ArgumentException: Schlusselwort wird nicht unterstutzt: 'provider'.", which must sound in english like keyword is not supported "provider").
After this, i tried to replace the Connection string with a hard coded value which i copy&pasted from the Report-Designer where you could build new connections to simply get it working, this looks like:
for(int i = 0; i < theDatabases.Length; i++) {
this.oReport.Dictionary.Databases.Add(new StiSqlDatabase(theDatabases,@"Provider=SQLOLEDB.1;Password=xxx;Persist Security Info=True;User ID=xxx;Initial Catalog=OXStundenzettel;Data Source=w2ka"));
}
This brings up the same error (System.ArgumentException: Schlusselwort wird nicht unterstutzt: 'provider'. / keyword is not supported 'provider').
As far as i can see, this is a valid connection string. Someone any idea what's the problem here ?
(maybe this helps, here's the callstack up to my method:
System.ArgumentException: Schlusselwort wird nicht unterstutzt: 'provider'.
bei System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
bei System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
bei System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
bei System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
bei System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
bei System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value)
bei System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
bei System.Data.SqlClient.SqlConnection..ctor(String connectionString)
bei Stimulsoft.Report.Dictionary.StiSqlAdapterService.CreateConnectionInDataStore(StiDictionary dictionary, StiSqlDatabase database)
bei Stimulsoft.Report.Dictionary.StiSqlDatabase.RegData(StiDictionary dictionary, Boolean loadData)
bei Stimulsoft.Report.Dictionary.StiDictionary.CreateDatabases(Boolean loadData)
bei Stimulsoft.Report.Dictionary.StiDictionary.Connect(Boolean loadData)
bei Stimulsoft.Report.Engine.StiRenderProviderV2.ConnectToData(StiReport report)
bei Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
bei Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
bei Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
bei Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
bei Stimulsoft.Report.StiReport.Render(Boolean showProgress)
bei OXStundenzettel.AFDPWindow.PrintPreview() in d:\AFSourcen\OXStundenzettel\AFDPWindow.cs:Zeile 87.
)
Thanks a lot for any reply!
With greetings from germany
Andre