I've opened up some example .dplx files in Designer and noticed the report's query connection can be set like so:
#Global.AppSettings["NorthwindConnectionString"]#
But I'm not seeing anything about that in the documentation. Could you point me in the right direction? I'm also interested in how to set the connection string programmatically at runtime.
Thank you.
documentation on ConnectionString
Re: documentation on ConnectionString
Support · Jun 28, 2011Hello,
Below are the links to documentation regarding connection strings.
Retrieve connection string from config file
Specify the connection string directly in the dplx file
It is not possible to change the connection string itself during runtime but you can set the data source during runtime by using “Event Driven Queries”. The data source here could be a data table or a list of objects. When you are using event driven queries you would need to set the query type to “Event Driven” in the query editor of the dplx file. Please refer to below links on more info.
Event driven queries
Using list of objects
Thanks,
ceTe Software Support Team.
Re: documentation on ConnectionString
Forum member · Jan 24, 2013So we are having to Encrypt our name and passwords in the web.config file for the connection string. So is there a way to set those values for the dplx file. from the aspx codebehind page. that way I can decrypt those values then pass them to the dplx file.
Re: documentation on ConnectionString
Support · Jan 24, 2013Hello,
The connection string can be changed in the code-behind during run-time as opposed to what we have said in our last post. Sorry for the confusion. Using the following code you can retrieve the query by name that you have specified in the dplx and then you can change the connection string property.
DocumentLayout doc = new DocumentLayout("test.dplx");
SqlQuery query = (SqlQuery)doc.GetElementById("Query1");
query.ConnectionString = "Set the unencrypted connection string here";
Document document = doc.Run();
document.Draw("test.pdf");
Thanks,
ceTe Software Support Team.
Re: documentation on ConnectionString
Forum member · Jan 28, 2013seems to not be working as planned.
I am using this code as I'm doing this in Asp.net VB.
Dim clPageID As String = Request.QueryString("clPageID")
clPageID = "928"
Parameters.Add("clPageID", clPageID)
layout = New DocumentLayout(Server.MapPath("/") & "apps\OSS\Cluster.dplx")
Dim query As ReportWriter.Data.SqlQuery = layout.GetElementById("Query")
query.ConnectionString = getConnectionStr("WMA")
doc = layout.Run(Parameters)
doc.DrawToWeb()
In my web.config the connection string has the username and password encrypted, the getConnectionStr function decrypts those.
when I step through the code. when I hit query and look at the properties it shows the connection string with the encrypted values, then after I run the getConnection function and look at query the properties show the decrypted values. But then when I hit the layout.run(Parameters) I get an error of '{"Login failed for user '+DKhpBcU8TMeU0RESxeWJg=='."} which is the encrypted value, so it's not actually using the new connection string I gave it. It appears to still be using the one set in the dplx file.
Re: documentation on ConnectionString
Forum member · Jan 28, 2013and if I remove the appSettings key which was setting the connection string, because now I was assuming I could use the connectinStrings in web.config I get an error that the connection string property has not been initialized. even though guery.connectionString does have a value. So I must be missing something somewhere.
Re: documentation on ConnectionString
Support · Jan 29, 2013Hello,
Please send over the following information to [^a|mailto:support@cete.com|opennewwindow|support@cete.com^] so we can look into this further.
1. Dplx file
2. Error message including the stack trace.
Thanks,
ceTe Software Support Team.
Re: documentation on ConnectionString
Forum member · Jan 29, 2013Thanks for your help, looks like it was my fault. I found a second query in the dplx file I didn't notice before. when I included it in my code also, it is working now. Thanks again