Record is not updating in a phonegap sqlite storage given in a particular query - sqlite

This is the query which is update single record in a table.
Where FriendTable.tablename and other column name is define a constant file.
Values which is to update is store in Friend variable.
FriendTable.updateValues=function(Friend,successCallback,errorCallback){
var query = 'update '+ FriendTable.tablename + ' set ' + FriendTable.lat + '=?,' + FriendTable.lon + '=?,' + FriendTable.locaddr + '=?,' + FriendTable.locts + '=? where ' + FriendTable.phonenumber + " =?";
app.dbobj.transaction(function (tx) {
console.log('Update Friend record :: ' + query);
console.log('Friend data :: ' + Friend.toString());
tx.executeSql(query,[Friend.lat,Friend.lon,Friend.locaddr,Friend.locts,Friend.phonenumber],successCallback,errorCallback);
});
}

Related

SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 15596 and this is thread id 10564

tableName = entityName + 's'
columnName = entityName
cursor.execute('SELECT rowid FROM ' + tableName + ' WHERE ' + columnName + ' = ?', (text,))
row = cursor.fetchone()
if row:
return row[0]
else:
cursor.execute('INSERT INTO ' + tableName + ' (' + columnName + ') VALUES (?)', (text,))
return cursor.lastrowid
Error:- cursor.execute('SELECT rowid FROM ' + tableName + ' WHERE ' +
columnName + ' = ?', (text,)) sqlite3.ProgrammingError: SQLite objects
created in a thread can only be used in that same thread. The object
was created in thread id 15596 and this is thread id 10564.
how i can solve this error.

AX 2012 View computed column returning Null

I have a View in AX with a computed column:
private static server str qty()
{
#define.THEN(" THEN ")
#define.SINGLE_QUOTE("'")
return 'CASE T2.ReturnStatus ' +
' WHEN ' + int2str(enum2int(ReturnStatusLine::None)) + #THEN + '-1 * T3.UnitValue' +
' WHEN ' + int2str(enum2int(ReturnStatusLine::Awaiting)) + #THEN + '-1 * T3.UnitValue' +
' WHEN ' + int2str(enum2int(ReturnStatusLine::Registered)) + #THEN + '-1 * T3.UnitValue' +
' ELSE ' + "(T3.UnitValue / T2.ExpectedRetQty * (SELECT TOP 1 SUM(cpst.Qty) as RcvQty from custPackingSlipTrans as cpst where cpst.InventTransId = T2.InventTransId and cpst.dataAreaId='" + curext() + "')) * -1" +
' END';
}
It works great, except the past week or so the column is returning NULL when it should not be. This is fixed simply by going into the AOT and syncing this view, after that the column has a valid value. But we're having to do this almost daily.
Any ideas?

MS Access - Combine varchar column with int column - ASP.net VB.net

I'm using an oledb connection string to connect my asp.net code to an access db
I can't seem to convert combine the 3 fields - ProductID(NUMBER)
ProductCode(TEXT), ProdDescription(TEXT)
Dim strQuery As String = "SELECT ProductID, (CAST(ProductID AS TEXT) + ' - '
+ ProductCode + ' - ' + ProdDescription) AS [Prod]
FROM [FG - End Product Codes]
ORDER BY ProductCode;"
I've also tried
(CAST(ProductID AS VARCHAR(10)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
And
(CONVERT(ProductID, TEXT)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
AND
(CAST(ProductID) AS VARCHAR(10)) + ' - ' + ProductCode + ' - ' + ProdDescription) AS [Prod]
AND
(CAST([ProductID] AS TEXT) + ' - ' + [ProductCode] + ' - ' + [ProdDescription]) AS [Prod]
Error msg: System.Data.OleDb.OleDbException:
'IErrorInfo.GetDescription failed with E_FAIL(0x80004005).'
error code : -2147467259
I seen the same error in another question but theirs seem to have some reserve keyword problem, If mine is the same, what is My reserved Keyword and where is it in my code?
thanks in advance
That's because you try to use T-SQL against Access which uses Access SQL. So, try this:
Dim strQuery As String = "SELECT ProductID, ProductID & ' - ' &
ProductCode & ' - ' & ProdDescription AS [Prod]
FROM [FG - End Product Codes]
ORDER BY ProductCode;"

Firebase function transaction handle null value

I'm trying to use firebase function transaction, but as I see there is no official way to handle the first cached null value...
I'm trying to do the following:
var team = event.data.child('team').val();
var tip = event.data.child('tip').val();
console.log('tip: ' + tip + ' | team: ' +team)
const pathToValue = admin.database().ref('users/' + event.params.userId + '/coins');
const pathToTeamBetsValue = admin.database().ref('matches/' + event.params.matchId + '/opponents/' + team + "/bets");
return pathToValue.transaction(function (coins) {
if (coins) {
if (coins >= tip) {
pathToTeamBetsValue.transaction(function (teamBets) {
if (teamBets) {
teamBets = teamBets + tips;
return teamBets;
}
});
admin.database().ref('bets/' + event.params.matchId + '/' + event.params.userId + '/status').set('inProgress');
coins = coins - tip;
}
else {
console.warn(event.params.userId + " new bet on match " + event.params.matchId + " was not successfull! (not enough coin)")
//return coins;
}
}
return coins;
})
so far as you can see I get some value which what should be decreased from the user's coins... unfortunately till now I could only get the behaviour which sets null in the user's coin value.. please help

using placeholder in sql query in asp.net

I am an ASP.Net developer & using sql server CE 4.0 I want to know how to use place holder for this code, As this query is currently vulnerable to sql injection. Place holder can prevent this but the problem is for example query = "SELECT * FROM TABLE WHERE TITLE = #0" but in my query the value of #0 is dynamically added to query how do i use place holder
this is the code
if (Request["search"] != "" && Request["search"] != null)
{
var search = Request["search"].Trim();
string[] querynew = search.Split(' ');
var searchquery = "and ";
foreach (string word in querynew)
{
searchquery += "response_table.adtitle LIKE '%" + word + "%' OR ";
}
sql += searchquery.Remove(searchquery.Length - 4);
}
if (Request["min"] != "" && Request["min"] != null && Request["max"] != null && Request["max"] != "")
{
sql = sql + " and (CAST(response_table.price AS Float)) between " + Request["min"].Trim() + " AND " + Request["max"].Trim();
}
// 3. the order clause
switch (Request["sort"])
{
case "recent":
sql = sql + "ORDER BY response_table.response_ID DESC OFFSET " + offset + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
break;
case "hightolow":
sql = sql + "ORDER BY CAST(response_table.price AS Float) Desc OFFSET " + offset + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
break;
case "lowtohigh":
sql = sql + "ORDER BY CAST(response_table.price AS Float) ASC OFFSET " + offset + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
break;
default:
break;
}
result = db.Query(sql);
Thank You
Using parameters (instead of concatenating strings) allows you to optimize performance of your queries.
You can use a SqlCeCommand. It has a collection of parameters and you can find a sample here regarding how to use them.

Resources