Page 1 of 2
ConnectionString
Posted: Fri Oct 22, 2010 7:17 am
by mansourweb
Dear Friends,
I have a report in c# windows application that its connectionstring is Password=123;Data Source=pc1\MAHMADI;Integrated Security=False;Initial Catalog=Commision;User ID=mahmadi in STIMULSOFT environment.
In c# i use the following code:
sr = (StiReport)report1.Clone();
sr.DataStore.Clear();
sr.RegData("Commision", "Password=123;Data Source=pc2\MAHMADI;Integrated Security=False;Initial Catalog=Commision;User ID=mahmadi");
sr.Compile();
sr.Show();
when i change the connectionstring from c# like above, it doesn't affect on the main report.
would you please direct me how change the name of pc that sql server installed, in connectionstring from c#?
in advanced, Thank you for your kindness.
ConnectionString
Posted: Fri Oct 22, 2010 8:25 am
by Alex K.
Hello,
You can see the article on our knowledgbase
http://stimulsoft.helpserve.com/index.p ... ticleid=15
Thank you.
ConnectionString
Posted: Fri Oct 22, 2010 9:17 am
by mansourweb
Dear Aleksey,
Thank you for your attention and response.
I add these two lines :
sr.Dictionary.Databases.Clear();
sr.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Commision", newConnectionString));
but it only show me empty report.
I have a table in my report. I thought , i must add table to sr.dictionary.database, but i don't know HOW?
would you please help me?
thank you.
ConnectionString
Posted: Sun Oct 24, 2010 6:10 am
by mansourweb
How can I change my connectionstring please ????
in my report , i use connection and datasource.
in connectionstring, my Data Source is pc2\MAHMADI , so if i install my software in the computer, i must change the datasource. how can i change it from C# code ??
Really thank you for your responses
ConnectionString
Posted: Mon Oct 25, 2010 5:19 am
by Alex K.
Hello,
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));
Add DataSources:
Code: Select all
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
report.Dictionary.DataSources.Add(DS1);
Add Columns:
Code: Select all
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Add Relations:
Code: Select all
StiDataRelation dataRelation = new StiDataRelation("MyRelation", parentDS, childDS, new string[] { "Field" }, new string[] { "Field" });
report.Dictionary.RegRelations();
report.Dictionary.Relations.Add(dataRelation);
Thank you.
ConnectionString
Posted: Thu Oct 28, 2010 1:22 am
by mansourweb
Dear Aleksey,
Thank you for your response. I wrote the following codes as you said. At first, I copy from my designed report, clear its previous database and add new one. it doesn't occur any errors but it show me empty error.
How i can fix it?
Really thank you.
Code: Select all
StiReport sr = new StiReport();
sr = (StiReport)nameersali.Clone();
sr.Dictionary.Databases.Clear();
string cs = @"Password=12343;Data Source=mansourpc\mahmadi;Integrated Security=False;Initial Catalog=Commision;User ID=mahmadi;";
/////////////////////////////////////////////////////////////////////////////////////
sr.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Commision", cs));
Stimulsoft.Report.Dictionary.StiSqlSource DS1 = new Stimulsoft.Report.Dictionary.StiSqlSource("Commision", "student", "student", "SELECT * FROM student", true, false);
sr.Dictionary.DataSources.Add(DS1);
/////////////////////////////////////////////////////////////////////////////////////
DataTable dataTableDS1 = DAL.qycustom("Select * from student");
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
sr.Show();
ConnectionString
Posted: Thu Oct 28, 2010 1:38 am
by mansourweb
Yes, Thank you Very Much. I change the code as below:
Code: Select all
StiReport sr = new StiReport();
sr = (StiReport)nameersali.Clone();
sr.Dictionary.Databases.Clear();
sr.Dictionary.DataSources.Clear();
sr.DataSources.Clear();
string cs = @"Password=1234;Data Source=mansourpc\mahmadi;Integrated Security=False;Initial Catalog=Commision;User ID=mahmadi;";
sr.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Commision", cs));
Stimulsoft.Report.Dictionary.StiSqlSource DS1 = new Stimulsoft.Report.Dictionary.StiSqlSource("Commision", "Student", "Student", "SELECT * FROM student", true, false);
sr.Dictionary.DataSources.Add(DS1);
///////////////////////////////////////////////////
DataTable dataTableDS1 = DAL.qycustom("Select * from student");
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
sr.Show();
ConnectionString
Posted: Thu Oct 28, 2010 1:45 am
by Alex K.
Hello,
Does this mean that the issue is solved?
Thank you.
ConnectionString
Posted: Fri Oct 29, 2010 11:05 am
by mansourweb
Hi,
Yes, Thank you :biggrin:
in the line below:
Stimulsoft.Report.Dictionary.StiSqlSource DS1 = new Stimulsoft.Report.Dictionary.StiSqlSource("Commision", "Student", "Student", "SELECT * FROM student", true, false);
i used student with small s, as in my designed report, it is with capital S. i change the student here with Student, and use your code and SOLVE.
thank you again.
ConnectionString
Posted: Mon Nov 01, 2010 12:30 am
by Alex K.
Hello,
We are always glad to help you!
Let us know if you need any additional help.
Thank you.