PDA

View Full Version : خطای مربوط به Relation در Stimul



nathan
پنج شنبه 21 دی 1391, 09:43 صبح
با سلام به دوستان عزیز مشکل عجیبی با یکی از گزارشهام دارم:
Datasource گزارش من دارای ۴ جدول هست که دو تای اینها باید با هم رابطه داشته باشند در حالت طراحی هیچ مشکلی نیست و به راحتی Preview می ده اما وقتی که دیتاست رو در کد می سازم و به گزارش پاس می دم این خطا رو می گیره "does not contain a definition for 'اسم اون relation'".
با استفاده از متد design() گزارش رو باز کردم که چیز خیلی عجیبی دیدم
98159

این تصویر دیتا سورس گزارش لود شده از داخل برنامه است در صورتیکه حالت اصلی اون باید این باشه:

98160

همونطور که می بینید نام Relation ها تغییر گرده و به واسطه همین تغییر در زمان Render یا Compile نمی تونه اون رابطه مورد نظر رو پیدا کنه و این خطا رو میده :

98161

دستور ساخت Relation ها هم اینهاست :




dstRep.Relations.Add("Rel2", dstRep.Tables["MasterTeacher"].Columns["Teacher"], dstRep.Tables["spRep_TeacherFishClass_Select"].Columns["TeacherCode"], true);
dstRep.Relations.Add("RelSub", dstRep.Tables["MasterTeacher"].Columns["Teacher"], dstRep.Tables["SubClass"].Columns["TeacherCode"], true);
dstRep.Relations.Add("RelMaster", dstRep.Tables["spRep_TeacherFishDelay_Select"].Columns["TeacherCode"], dstRep.Tables["spRep_TeacherFishClass_Select"].Columns["TeacherCode"], true);

nathan
پنج شنبه 21 دی 1391, 11:18 صبح
یه نکته که باید اضافه کنم اینه که در اصل نام جدول Parent رو روی Relation می ذاره نه اون اسمی رو که ما مشخص کردیم. حتی این کدها هم کار نمی کنه!:




Report.Dictionary.RegRelation(new Stimulsoft.Report.Dictionary.StiDataRelation("RelMaster", "RelMaster", "RelMaster", Report.DataSources["spRep_TeacherFishDelay_Select"], Report.DataSources["spRep_TeacherFishClass_Select"], new string[] { "TeacherCode" }, new string[] { "TeacherCode" }));
Report.Dictionary.RegRelation(new Stimulsoft.Report.Dictionary.StiDataRelation("Rel2", "Rel2", "Rel2", Report.DataSources["MasterTeacher"], Report.DataSources["spRep_TeacherFishClass_Select"], new string[] { "Teacher" }, new string[] { "TeacherCode" }));

nathan
پنج شنبه 21 دی 1391, 11:49 صبح
دوستان از این کد ها استفاده کنید حله!




Stimulsoft.Report.Dictionary.StiDataRelation RelMaster = new Stimulsoft.Report.Dictionary.StiDataRelation("RelMaster", Report.Dictionary.DataSources["spRep_TeacherFishDelay_Select"], Report.Dictionary.DataSources["spRep_TeacherFishClass_Select"], new System.String[] { "TeacherCode" }, new System.String[] { "TeacherCode" });
Stimulsoft.Report.Dictionary.StiDataRelation Rel2 = new Stimulsoft.Report.Dictionary.StiDataRelation("Rel2", Report.Dictionary.DataSources["MasterTeacher"], Report.Dictionary.DataSources["spRep_TeacherFishClass_Select"], new System.String[] { "Teacher" }, new System.String[] { "TeacherCode" });
Stimulsoft.Report.Dictionary.StiDataRelation RelSub = new Stimulsoft.Report.Dictionary.StiDataRelation("RelSub", Report.Dictionary.DataSources["MasterTeacher"], Report.Dictionary.DataSources["SubClass"], new System.String[] { "Teacher" }, new System.String[] { "TeacherCode" });

Report.Dictionary.RegRelations();
Report.Dictionary.Relations.Add(RelMaster);
Report.Dictionary.Relations.Add(Rel2);
Report.Dictionary.Relations.Add(RelSub);

nathan
پنج شنبه 21 دی 1391, 11:51 صبح
باورتون میشه ۳ شبه که زودتر از ساعت ۳ نخوابیدم من برم یه ذره بمیرم