Page 1 of 1

How can I work with a complete dataset template?

Posted: Tue Jan 10, 2012 7:52 am
by gustavo
The idea was to provide a full database template to let designers work with any restriction...
but in my test, i'm working with 2 tables with relations...

so... when this report is rendered, i need to fill this two dataset tables...
and if i put all my tables in this dataset?

what is the best way to work with this?
or how can i provide all the database tables/fields to designers without show the connection string (that is a problem for us too)...


How can I work with a complete dataset template?

Posted: Tue Jan 10, 2012 8:26 am
by Alex K.
Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?

Thank you.

How can I work with a complete dataset template?

Posted: Tue Jan 10, 2012 8:50 am
by gustavo
i created a dataset file and inserted all my database tables on it...

when i create i new report...
StiReport report = new StiReport();
report.RegData("Data", new MyDataSet);
report.Dictionary.Synchronize();

this allow the designers to create reports usning any table that they want.

but the problem comes when i show de report...
because i don't know wich tables the designers have used...

so... in this case i fill all tables from MyDataSet with database records... (select * from .... ) using SQL adapter.

in Render method i have this "Ugly" code:

System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(MyConnectionString);
System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select * from Product", conn);
System.Data.SqlClient.SqlDataAdapter da2 = new System.Data.SqlClient.SqlDataAdapter("select * from Order", conn);
..
.

MyDataSet ds = new MyDataSet();
da.Fill(ds.Product);
da2.Fill(ds.Order);
..
.

report.RegData("Kankei", MyDataSet);


and my question is:
How can i make it better?

example: Using a direct connection to database... but i cannot show the connection string to designers...


How can I work with a complete dataset template?

Posted: Tue Jan 10, 2012 9:48 am
by HighAley
Hello.

You could hide connection string using next code:

Code: Select all

report.Dictionary.Restrictions.Add("DataSourceName", StiDataType.DataSource, StiRestrictionTypes.DenyEdit);
StiConfig.HideProperty("SqlCommand");
Does it meet your needs?

Thank you.

How can I work with a complete dataset template?

Posted: Tue Jan 10, 2012 12:16 pm
by gustavo
but as Aleksey's reply on this post:
http://forum.stimulsoft.com/Default.asp ... 167&#24167

this command is not avaliable at the moment for this current version..
"report.Dictionary.Restrictions.Add("DataSourceName", StiDataType.DataSource, StiRestrictionTypes.DenyEdit);"

but i founded a better solution in another post...
I'm using this method to get the used tables from my registered dataset

var dataTables = StiDataSourceHelper.GetUsedDataSourcesNames(report).Keys.Cast().ToArray();
foreach (var tableName in dataTables)
{
SqlDataAdapter da = new SqlDataAdapter("select * from " + tableName, conn);
da.Fill(MyDataSet.Tables[tableName]);
}

Thanks for the help!!
but i would like to see this Dictionary.Restrictions working for silverlight designers too
or if its working in the current version... i'm using 2011.3... let me know!!



How can I work with a complete dataset template?

Posted: Wed Jan 11, 2012 2:13 am
by HighAley
Hello
gustavo wrote:but i would like to see this Dictionary.Restrictions working for silverlight designers too
or if its working in the current version... i'm using 2011.3... let me know!!
We made some improvements. Please, check our next prerelease build this week.

Thank you.