Page 1 of 1
StiSqlSource
Posted: Thu Jul 18, 2013 3:31 am
by Dobermaxx99
How can I get the columns from a StiSqlSource
StiSqlSource DS1 = new StiSqlSource("QC14", "a_acct_class", "a_acct_class", "SELECT * FROM a_acct_class where acct_class LIKE @class");
foreach (DataColumn col in DS1)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
report.Dictionary.DataSources.Add(DS1);
report.Compile();
not working.

Re: StiSqlSource
Posted: Thu Jul 18, 2013 7:05 am
by Alex K.
Hello,
Please check the following code:
Code: Select all
StiReport report = new StiReport();
string newConnectionString = @"Data Source=ALEKSEYPC\SE2012;Initial Catalog=Northwind;Integrated Security=True";
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", newConnectionString));
StiSqlSource Categories = new StiSqlSource("Connection", "Categories", "Categories", "SELECT * FROM Categories", true, false);
report.Dictionary.DataSources.Add(Categories);
using (SqlConnection connection = new SqlConnection(newConnectionString))
{
SqlDataAdapter dataCategories = new SqlDataAdapter("select * from Categories", connection);
DataTable dataTableCategories = new DataTable();
dataCategories.Fill(dataTableCategories);
foreach (DataColumn col in dataTableCategories.Columns)
{
Categories.Columns.Add(col.ColumnName, col.DataType);
}
}
Thank you.
Re: StiSqlSource
Posted: Thu Jul 18, 2013 12:13 pm
by Dobermaxx99
Thanks Aleksey! so theres no way to get the columns by just using StiSqlSource?
Re: StiSqlSource
Posted: Fri Jul 19, 2013 6:20 am
by Alex K.
Hello,
Please try to use the following code:
Code: Select all
StiSqlSource DS1 = new StiSqlSource("QC14", "a_acct_class", "a_acct_class", "SELECT * FROM a_acct_class where acct_class LIKE @class");
DS1.Columns.Add("Column1", "Column1Alias", typeof(string));
DS1.Columns.Add("Column2", "Column2Alias", typeof(string));
report.Dictionary.DataSources.Add(DS1);
Thank you.