I am evaluating this product for use in multiple applications we have. I am finding the lack of examples to do SQL database connections and data sources in the back end of the designer somewhat lacking. I have pieced the basics together from various forum posts.
What i would like to do is, when adding each datasource for a new report, it should auto retrieve the column names. I notice it can be done via the front end, but i cannot see any method from the back end. I don't want my users typing in SQL to create there own datasources - they should all be listed ready for them.
I saw this post: http://forum.stimulsoft.com/Default.aspx?g=posts&t=4715
which talks about this. I downloaded the 1 Sept trial version, and still can't see how to do it. Can someone point me in the right direction? (I know i can write some code to do this, but i would think that functionality is already in there somewhere).
Thanks - the rest of the product looks really good!
Auto-Create columns from datasource
Auto-Create columns from datasource
Hello,
You can use the following code.
New connection string:
Add DataSources:
Add Columns:
Thank you.
You can use the following code.
New connection string:
Code: Select all
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", newConnectionString));
Code: Select all
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
report.Dictionary.DataSources.Add(DS1);
Code: Select all
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Re: Auto-Create columns from datasource
Hello,
I have the same issue, and I do not understand where the variable "dataTableDS1" comes from, in the code you have posted.
(I am implementing this in Javascript, by the way). Could you be more specific about how I could get the dataTableDS1 object correctly filled with the columns of the table?
I have the same issue, and I do not understand where the variable "dataTableDS1" comes from, in the code you have posted.
(I am implementing this in Javascript, by the way). Could you be more specific about how I could get the dataTableDS1 object correctly filled with the columns of the table?
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
-
- Posts: 6263
- Joined: Tue Mar 20, 2018 5:34 am
Re: Auto-Create columns from datasource
Hello,
You can use the following code:
Thank you.
You can use the following code:
Code: Select all
var connection = new SqlConnection("connection");
var adapterDataTable1 = new SqlDataAdapter("select * from Table1", connection);
var dataTable1 = new DataTable();
adapterDataTable1.Fill(dataTable1);
foreach (DataColumn col in dataTable1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Re: Auto-Create columns from datasource
Hi Lech,
Thank you for your answer. Though, since I am working using JS (Stimulsoft.Report.JS), I don't really get how I can convert the dataType I have from my NodeJS SQL Adapter to a Stimulsoft.System.Type object... Unless you can provide me with the solution here, I will create a post in the appropriate section of the forum.
Kind Regards,
Thank you for your answer. Though, since I am working using JS (Stimulsoft.Report.JS), I don't really get how I can convert the dataType I have from my NodeJS SQL Adapter to a Stimulsoft.System.Type object... Unless you can provide me with the solution here, I will create a post in the appropriate section of the forum.
Kind Regards,
-
- Posts: 6263
- Joined: Tue Mar 20, 2018 5:34 am
Re: Auto-Create columns from datasource
Hello,
Please check the following link:
https://admin.stimulsoft.com/documentat ... erence-js/
Thank you.
Please check the following link:
https://admin.stimulsoft.com/documentat ... erence-js/
Thank you.