"change connection string in stimulsoft in run time dos not work" - stimulsoft

//hi every one i am beginner in stimullsoft this is my code for change connection string //in stimullsoft 2012 in run time but it dos not return any things please help me
rpt_nogoresd_bij.Dictionary.Databases.Clear();
rpt_nogoresd_bij.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("mashaghel", str_connect ));
rpt_nogoresd_bij.Dictionary.Variables["date"].Value = txt_date.Text;
rpt_nogoresd_bij.Dictionary.Variables["azhozeh"].Value = "220111";
rpt_nogoresd_bij.Dictionary.Variables["tahozeh"].Value = "220623";
rpt_nogoresd_bij.Dictionary.Variables["sal"].Value = "1391";
rpt_nogoresd_bij.Show();

please declare you variables type, ex: int - char and ...
and You have not saved the report templates.
Add the rpt_nogoresd_bij.Save() method.

Related

How to display default value from prompt macro in value prompt CA11?

I was wondering if it is possible to display the default value from a prompt macro in a Value prompt. My prompt macro looks like this "#prompt('pMonth','MUN','[Previous Month]')#"
so my goal in the value prompt would be to have 202103 displayed instead of header text name which I have named "Previous Month"
I tried with an old javascript from Cognos 10 where you desc the Months and specify what index it should pick but the issue with that code is that everytime you try to change to a different month the report re-runs and loops back to to the same Index value.
<script>
var theSpan = document.getElementById("A1");
var a = theSpan.getElementsByTagName("select"); /* This stmt return an array of all value prompts within span */
for( var i = a.length-1; i >= 0; i-- ) /* now loop through the elements */
{ var prompts = a[i];
if( prompts.id.match(/PRMT_SV_/))
{ prompts.selectedIndex = 2; } /* This selects the second options from top */
canSubmitPrompt();
}
</script>
All solutions, tips and ideas are highly appreciated.
Best regards,
Rubrix
For Cognos Analytics, running with full interactivity, you probably need a Page Module. Check out IBM's Scriptable Reports documentation for Cognos Analytics. You'll want to craft your script to use the current parameter value as default (if you can get it), then fail over to your default value from the data. You will probably need to integrate this with a Custom Control to be able to get that default value from the data.

IBM Lotus - updating room reservation, room name is appended to LOCATION each time

I have a custom XPage java REST api in Lotus to handle reservations, everything is going well so far.
I have one weird "problem" though, whenever I update a meeting, the room name (like Test room/Site) is being appended to the LOCATION in iCalendar string.
The way I'm updating appointments is by finding the entry in user's calendar (NotesCalendar.getEntryByUID), then I call NotesCalendarEntry.read() to get the iCalendar string, I then manually replace values of certain iCalendar fields, like DTSTART to the ones I wish to update (I'm only updating DTSTART, DTEND and SUMMARY). Finally I call NotesCalendarEntry.update(string) to update the event.
It works well, however with each update, the LOCATION field grows bigger and bigger, because the room name is being constantly appended to it, and finally it looks like:
LOCATION: Test Room/Test SiteTest Room/Test SiteTest Room/Test Site
etc.
Am I doing something wrong? How can I prevent this? I don't want to clear the location field each time, because users can put their own location and I'd like to keep it (in that case room name is also being appended to the original location text)
Code:
NotesCalendar cal = session.getCalendar( session.getDbDirectory( session.getServerName() ).openMailDatabase() );
NotesCalendarEntry calEntry = cal.getEntryByUNID(apptUNID); // apptUNID is taken from http json payload
String iCalE = calEntry.read();
// 20190326T160000Z
String dStart = DateUtil.formatICalendar(dtStart);
String dEnd = DateUtil.formatICalendar(dtEnd);
iCalE = iCalE.replace("\\n", ""); // I added this because same was happening to literal \n (not actual line breaks)
StringBuilder sb = new StringBuilder(iCalE);
int StartIndex = iCalE.indexOf("BEGIN:VEVENT"); // DTSTART is also in BEGIN:VTIMEZONE so we need to exclude that
int tmpIndex = iCalE.indexOf("DTSTART", StartIndex) + 7; // 7 = len of DTSTART
int LineBreakIndex = iCalE.indexOf('\n', tmpIndex);
if(iCalE.charAt(LineBreakIndex-1) == '\r')
LineBreakIndex--;
sb.delete(tmpIndex, LineBreakIndex);
sb.insert(tmpIndex, ":" + dStart); // start date
tmpIndex = sb.indexOf("DTEND", StartIndex) + 5;
LineBreakIndex = sb.indexOf(Character.toString('\n'), tmpIndex);
if(sb.charAt(LineBreakIndex-1) == '\r')
LineBreakIndex--;
sb.delete(tmpIndex, LineBreakIndex);
sb.insert(tmpIndex, ":" + dEnd);
calEntry.update(sb.toString());
calEntry.recycle();
Also, can I safely assume that iCalendar lines are always ended with \r\n ? (they currently are, I had some problems with that but I figured it out, I'm not sure if I can safely look for '\r\n' though)
I dont use ical4j because I'm literally only modifying 2 or 3 fields and nothing else.

Sorting a Listbox in C++

first time asking questions here. I'm having trouble sorting a listbox in a c++ form. I would much rather do this in C# but it's a class requirement unfortunately. Here's the code in question:
void updateCourseDisplay()
{
courseListBox->Items->Clear();
set<Course*> courseSet = courseControl->getCourseSet();
std::set<Course *>::iterator it;
for (it = courseSet.begin(); it != courseSet.end(); ++it)
{
Course * c = (*it);
String ^courseId = gcnew String((c->getID().c_str()));
String ^courseName = gcnew String((c->getName().c_str()));
courseListBox->Items->Add(courseId + " - " + courseName);
}
courseListBox->System::Windows::Forms::ListBox::Sort();
populateCopyStudentsComboBox();
}
I know this is pretty messy but I didn't want to mess around with creating managed objects to add to the form. The error I'm getting when I try and run this says that System::Windows::Forms::ListBox::Sort() would have been called but it is inaccessible. All I want is simple ordering of the list by the string value. Any thoughts?
Sort is a protected method that can not be accessed from the "outside". You should set the public Sorted property to true instead.

SQL Server CE and Datetime Select issue (C#)

I have a select that uses datetime, from two datetimepickers, in the WHERE clause. The SELECT runs fine, populates a datagrid, no problem, but bizzarely the datetime part of the SELECT is completely ignored and the whole thing returns a recordset as if only "WHERE x_account_id = " + subaccountID were employed:
SqlCeConnection conn = new SqlCeConnection(Lib.ConnectionString);
string sql = "SELECT x_scaleid, x_weight, x_timestamp FROM x WHERE x_account_id = " + subaccountID
+ " AND (x_timestamp BETWEEN #start_date AND #end_date) ORDER BY x_timestamp DESC";
SqlCeCommand cmd = new SqlCeCommand(sql, conn);
cmd.Parameters.Add("#start_date", SqlDbType.DateTime, 8).Value = dFromFilter.Value.Date;
cmd.Parameters.Add("#end_date", SqlDbType.DateTime, 8).Value = dToFilter.Value.Date;
SqlCeDataAdapter da = new SqlCeDataAdapter();
da.SelectCommand = cmd;
Not been able to find anyone with the same issue online, so I'm kind of stuck. Maybe I'm better off trying to convert all the datetimes to int's, and store them that way - always hated working with datetime types.
Before anyone asks, I've tried various versions of the clause, including the use of '<' and '>', as well as different CONVERT variations.
I 'solved' the issue, and by 'solved' I mean put in a hack.
I created a new column in the DB, type int, in the x table. As I populate x_timestamp with the current time, derived from the application, I populate this new column with a number constructed out of the date, in the format of 'yyyymmdd'. So when doing any filtering, using dates, I can simply do a numerical comparison using the two dates picked (again converted to similar int formats in the application). Works a treat.
It's not an ideal solution by any stretch, as it duplicates data in the DB, but deadlines are deadlines and if no one else can suggest a better one here, this one may be of help to anyone else with a similar problem in the future.

How to solve the "String" in "for each" loop

My task is to open multiple files after a button clicked, and read all those selected files.
I have found an example of foreach function in c#, but I would like to write it in C++. How should I actually to convert that?
It shows the error that System::String, cannot use this type here without top level '^'.
I'm still new with that. Does anyone can give suggestion?
Thank you very much.
Below is my written codes
Stream^ myStream;
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
openFileDialog1->InitialDirectory = "c:\\";
openFileDialog1->Title = "open captured file";
openFileDialog1->Filter = "CP files (*.cp)|*.cp|All files (*.*)|*.*|txt files (*.txt)|*.txt";
openFileDialog1->FilterIndex = 2;
//openFileDialog1->RestoreDirectory = true;
openFileDialog1->Multiselect = true;
if ( openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK )
{
**for each (String line in openFileDialog1->FileName)**
System::Diagnostics::Debug::WriteLine("{0}",line);
myStream->Close();
}
Depending on the Container type returned, there is a std::for_each defined in <algorithm>-header.
The function Looks like this:
#include <algorithm>
std::for_each(InputIterator first, InputIterator last, Function fn);
You need to provide two iterators, one for the beginning of the Container and one for the end of the iterator. As a third Argument you can provide a function (function-object) and operate on the current argument.
See here for further reference.
As I got it from MSDN, the property SafeFileNames returns an array<String^>.
System::Array provides a static method called Array::ForEach. You would need to call it like
System::Action<T> myAction; // You will Need to provide a function here to be used on every filename.
System::Array::ForEach(openFileDialog1->SafeFileNames, myAction);
This comes closest to foreach from C#.
Look here for System::Array::ForEach and here for OpenFileDialog::SafeFileNames.

Resources