I have a bash script , from which i run js file which is responsible to update the table with a new filed if it doesn't exists .
But while executing bash script , i am getting the following error .
Wed Jul 3 00:05:18 Error: error doing update (anon):1552
failed to load: logincount.js
This is a simple js file which will update a field called as yesterday inside userCollection table
var d = new Date();
var curr_date = d.getDate()-1;
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();
var yesterday = curr_year + "-" + curr_month + "-" + curr_date;
db.userCollection.update({yesterday : {$exists : false}}, {$set: {yesterday : yesterday}},false,true)
Please let me know if there is any wrong the above js file and what is the reason for this error ??
please advice , thanks in advance
One more thing i have forgot to update if i remove the last line , the below line
db.userCollection.update({yesterday : {$exists : false}}, {$set: {yesterday : yesterday}},false,true)
it doesn't complain anything . i guess that if the filed yesterday should be global or what ?? if yes then how can i make that field global ??
The variable db is not defined. Take a look here: http://docs.mongodb.org/manual/tutorial/write-scripts-for-the-mongo-shell/
You can do this:
conn = new Mongo();
db = conn.getDB("myDatabase");
or this:
db = connect("localhost:27020/myDatabase");
Related
I'm trying to return a single calendaritem from Outlook from our C# windows desktop application. It keeps returning this error:
Redemption.RDOItems
Assertion failed: Number of fields == 1.
I use similar code in an Outlook addin I created and it works fine. The main difference is the filterprefix.
In the AddIn I use:
string filterprefix = "[" + OurCustomProperty.OurItemId + "] = '";
var filter1 = filterprefix + parentItem.NeedlesId + "'";
var findItem = folder.Items.Find(filter1);
but this code does not work from our desktop app.
Here is the code from the desktop App which is returning the error:
The appointment.Id contains a valid value which we set when we create the item.
string Filterprefix = "#SQL="+"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/OurCustomProperty.OurItemId/0x0000001f = '";
RDOSession rdoSession = new RDOSession();
rdoSession.Logon("", "", false, false, null, false);
RDOFolder folderRDO = rdoSession.GetDefaultFolder(rdoDefaultFolders.olFolderCalendar);
var filter1 = filterprefix + appointment.Id + "'";
string ls_find = Filterprefix + appointment.Id + "'" ;
var findItem = folderRDO.Items.Find(ls_find);
I've tried several variations of the syntax but can't seem to get it right.
I also tried using Sort then Restrict but no luck with that either.
Thanks, Rick
RDOItems.Find takes a SQL statement, please do not use the #SQL= prefix - it is OOM specific. Also do not forget to doublequote the DASL property name:
"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/OurCustomProperty.OurItemId/0x0000001f" = '<some value>'
How can I insert a date like '2017-2018' using faker in laravel.
I can get the year by
$startYear = $faker->year('now');
But I want to insert like '2017-2018' or '2018-2019' etc.
You could just add 1 to the year you got from Faker. E.g.:
$startYear = $faker->year('now'); // 2017
$endYear = $startYear + 1; // 2018
$result = $startYear . "-" . $endYear; // 2017-2018
This code worked good on ph 5.3. My server got upgraded to php5.6 and now the code no longer works.
Here is the two statements.
$sql = "UPDATE " . FORUM_TOUR_TABLE . "
SET page_subject = '$subject', page_text = '$message', page_access = $page_access
WHERE page_id = $id";
It says :
`SQL Error : 1064 Syntax error near 'WHERE page_id = 1' at line 3
UPDATE SET phpbb_forum_tour page_subject = ' Welcome To The Tower' , page_text = ' Update me please ' = WHERE page_access page_id = 1
Line : 172
File: admin_forum_tour.php`
That happens when I try to update a post.
When I try to add a new post using this code:
$sql = "INSERT INTO " . FORUM_TOUR_TABLE . " (page_id, page_subject, page_text, page_sort, bbcode_uid, page_access)
VALUES ($id, '$subject', '$message', $page, '$bbcode_uid', $page_access)";
This gives me this:
`SQL Error : 1064 Syntax error near ')' at line 2
INSERT INTO phpbb_forum_tour ( page_id , page_subject , page_text , page_sort , bbcode_uid , page_access ) VALUES (3, '2 Word Rule ', ' Hello World I am here ', 30 , ' f4e1be18dc ' )
Line : 198
File: admin_forum_tour.php`
I 100% apologize for asking this as I am more than sure it has been beat to death. I have been searching for a couple hours now and have all but given up. I had it working once but was told I opened my self up to injection. I am not a pro coder. I get lucky sometimes and make things work. I am sure these errors and code is basic to most but I am still learning.
Thanks for helping and understanding my "newbieness".
I am getting the following error using infor-eam MP0303_SyncAssetEquipment:
"Commission Date field cannot be blank."
I have coded for the commission date:
getrequest.AssetEquipment.COMMISSIONDATE = new MP0303_SyncAssetEquipment_001.DATETIME();
getrequest.AssetEquipment.COMMISSIONDATE.YEAR = result.AssetEquipment.COMMISSIONDATE.YEAR;
getrequest.AssetEquipment.COMMISSIONDATE.MONTH = result.AssetEquipment.COMMISSIONDATE.MONTH;
getrequest.AssetEquipment.COMMISSIONDATE.DAY = result.AssetEquipment.COMMISSIONDATE.DAY;
getrequest.AssetEquipment.COMMISSIONDATE.HOUR = result.AssetEquipment.COMMISSIONDATE.HOUR;
getrequest.AssetEquipment.COMMISSIONDATE.MINUTE = result.AssetEquipment.COMMISSIONDATE.MINUTE;
getrequest.AssetEquipment.COMMISSIONDATE.SECOND = result.AssetEquipment.COMMISSIONDATE.SECOND;
getrequest.AssetEquipment.COMMISSIONDATE.SUBSECOND = result.AssetEquipment.COMMISSIONDATE.SUBSECOND;
getrequest.AssetEquipment.COMMISSIONDATE.TIMEZONE = result.AssetEquipment.COMMISSIONDATE.TIMEZONE;
But still getting the same error message. Any ideas?
Thanks Before Hand
You are missing these:
getrequest.AssetEquipment.COMMISSIONDATE.qualifier = new MP0303_SyncAssetEquipment_001.DATETIMEqual();
getrequest.AssetEquipment.COMMISSIONDATE.qualifier = (MP0303_SyncAssetEquipment_001.DATETIMEqual)result.AssetEquipment.COMMISSIONDATE.qualifier;
I have a text file that contains some data in a "block" format:
source : source location
filename : somefile.txt
vendor : somevendor
version : xx.xx.xxx
source : source location2
filename : somefile2.txt
vendor : somevendor2
version : yy.yy.yyy
can I use Linq to query this data and if so how would you go about it? I have used linq to query lines of data from text file many times, but never a "block" of data as above. Thanks for the input.
Yes, you can use LINQ, this approach is not optimized much if you have large file. Below is how to get data:
var lines = File.ReadLines("C:\\text.txt")
.Where(line => !string.IsNullOrWhiteSpace(line))
.ToList();
for (int i = 0; i < lines.Count; i += 4)
{
var location = lines[i].Split(':')[1];
var fileName = lines[i + 1].Split(':')[1];
var vendor = lines[i + 2].Split(':')[1];
var version = lines[i + 3].Split(':')[1];
}
Version to use LINQ:
var result = Enumerable.Range(0, lines.Count()/4).Select(i => new {
location = lines[4*i].Split(':')[1];
fileName = lines[4*i + 1].Split(':')[1];
vendor = lines[4*i + 2].Split(':')[1];
version = lines[4*i + 3].Split(':')[1];
});