Chinese Characters not being updated in SQL field - sql

I have an update statement with Chinese characters in the data like so...
UPDATE table SET col1 = N'点心' WHERE id = 123
I am declaring the content type as UTF-8. For some reason, the field get updated with this:
自然地解é
The field is a nvarchar in MSSQL. Any ideas?
**EDIT
I am using a jQuery ajax call to write the data:
jQuery.ajax({
type: "POST",
url: "ajax/call.asp",
data: { value: value },
contentType:"application/x-www-form-urlencoded;charset=UTF-8",
dataType: "json",
success: function(msg){}
});
** EDIT
Page 1 is:
<script>
var value = "<%=value%>";
jQuery.ajax({
type: "POST",
url: "ajax/call.asp",
data: { value: value },
contentType:"application/x-www-form-urlencoded;charset=UTF-8",
dataType: "json",
success : function(responseData) {}
});
</script>
Page 2 is:
value = Request("value")
IF value <> "" THEN
SQL = "UPDATE table SET col1 = N'"& value &"' WHERE ID = '123'"
objconn.execute(SQL)
END IF

Figured it out. My text editor wasn't saving the ajax file as UTF-8 UOM. Once it saved this way, it worked.

Related

How to construct Parse Objects from JSONs?

I have JSONs like this;
{
createdAt: a_date,
text: "some text",
likes: 8
}
And I want to convert them into PFObjects… here’s how I do it;
let post = PFObject(className: "Post", dictionary: jsonPost)
The thing is that after that, the PFObject doesn’t have a value at its createdAt property.
post.createdAt <== this is always nil
I did some digging and tried this, but still no success;
jsonPost["_created_at"] = ["__type": "Date", "iso": "2020-09-23T13:31:08.877Z"]
Any idea why?
I think you might need to manually assign each param:
let postJson = {
createdAt: a_date,
text: "some text",
likes: 8
};
// create the Parse Object with Class 'Post'
let post = Parse.Object.extend('Post');
// assign param
post.set('text', postJson.text)
post.set('likes',postJson.likes)
post.save().then()...
createdAt is automatically handled by Parse Server when you save an object. If you want to manually control it with your own timestamp, then you will need to add a field:
post.set('myCreatedAt',postJson.createdAt)

Executing Script after serializeFileUpload

I don't know if it is possible, but I like to show a picture after uploading it into the Library.
As soon as I want to cascade the serializeFileUpload I get an error and the method comment also states that serializeFileUpload may be the only callback.
My code so far:
html fileUpload
...
id: #fileUpload;
onChange: (html jQuery ajax
serializeFileUpload: (html jQuery id: inputString ));
callback: [ :f | self handleNewFile: f]
Is there a way to have the jQuery replace #fileUpload with the uploaded image?
Thanks
Max
Implementation in JQAjax>>serializeFileUpload:aQuery
self
data:
((((JSStream on: 'var formdata = new FormData()'),
((aQuery copy attributeAt: 'name') assignLocalTo: 'name'),
(((aQuery property: 0) access: 'files') assignLocalTo: 'files'),
(JSStream on:'for(i=0;i<files.length;i++) formdata.append(name,files[i])'),
(JSStream on: 'return formdata')) asFunction) apply: #());
url: self renderContext actionUrl;
type: 'POST';
cache: false;
processData: false;
contentType: false
Have you tried to use the ajax onsucces callback?
(html jQuery ajax
...
onSuccess: ((html jQuery id: #fileUpload) replaceWith: [:r | ... ]))

dojo FilteringSelect avoid Accented characters

I'm using a FilteringSelect that use an FilteringSelect as store.
I want to ignore the accented characters that users can enter, and to return all the elements with or without accents. But i don't know what event i have to catch.
Here's my code :
var ccppMemory = new dojo.store.FilteringSelect({
data: centrosPoblado,
idProperty: "id"
});
sboMunicipio = new dijit.form.FilteringSelect({
id: "soMunicipioSelect",
hasDownArrow: false,
placeholder: i18n.tools.searches.ordinary.departmentTown,
store: ccppMemory,
searchAttr: "unitario",
intermediateChanges : true,
queryExpr: "*${0}*",
autoComplete: false,
highlightMatch: "all",
style:"margin-right:5px;width:170px;"
}, "soMunicipioSelect");
sboMunicipio.startup();
To explain better, centrosPoblado is an array that i populate as :
centrosPoblado.push({
id: value.attributes.CODIGO_DANE,
label: value.attributes.NOMBRE_CENTRO_POBLADO,
unitario: value.attributes.DEPTO + " / " + value.attributes.NOMBRE_CENTRO_POBLADO
});
In 'unitario' i have store strings like 'Medellín', ' Bogotá', ....
What i want is that when a user enter medellín, the filterselect ignore and returns 'Medellín' . So what i think i have to do it's to substitute medellin for something like m[eé]d[eé]ll[íi]n, but i don't know where.
Thanks
if anyone is interested, here is the answer :
http://dojo-toolkit.33424.n3.nabble.com/FilteringSelect-avoid-Accented-characters-td4004099.html
You have to overwrite the 'queryEngine' of the Memory that its linked to the FilteringSelect

jqGrid pager only returning first page

I want to have client side paging.
But for some reason, I only seem to get back the first page? Even though I know I have two pages worth of data (IE... I step through my code, and I definitely have two...)... What is more baffling is that my links to navigate through the pages never seem to be correct... For instance I would expect the following screen to say 1 of 2...
Also I would expect the bottom right hand side to say View 1-15 of 21?
My feeling is that I am doing something wrong in my data layer to give this pager it's info.
So It only returns the first page.
public static string JsonifyEnc(IEnumerable<TemplateModel> model, int popId, int page, int rows) {
TemplateModel variable = model.ToArray()[0];
ArrayList al = new ArrayList();
//foreach (PatientACOModel patMod in variable.Template) {
int i = 1;
int rowstart = (page * rows + 1) - rows;
int rowend = page * rows;
//Here is where I create the rows... nothing special here
var griddata = new {
total = variable.Template.Count % rows > 0 ? (variable.Template.Count / rows) + 1 : (variable.Template.Count / rows),
page = page,
records = al.Count,
rows = al.ToArray()
};
When I quick wath the total variable it says two?
This would be the first part of my json string that is returned...
{"total":2,"page":1,"records":15,"rows":
So it's there. Also, this is how I am building up my jqGrid...
$(document).ready(function () {
jQuery("#frTable").jqGrid ({
cmTemplate: { sortable: false },
caption: '#TempData["POPNAME"]' + ' Population',
datatype: 'json',
mtype: 'GET',
url: '/Encounters/GetAjaxPagedGridData/', //'Url.Action("GetAjaxPagedGridData", "Encounters", new { popId = TempData["POPULATIONID"] })',//
postData: { popId: '#TempData["POPULATIONID"]'},
pager: '#pager',
jsonReader: {repeatitems: false},
loadonce: true,
height: 'auto',
gridview: true,
viewrecords: true,
rowNum: 15,
shrinkToFit: false,
autowidth: true,
If you use loadonce: true on the client side you should change the server code so that it ignores page and rows options and returns all data. You should just sort the data corresponds to sidx and sord parameter (see sortname and sortorder in jqGrid). You don't need to fill total, page and records parts in the response.
If you use loadonce: true jqGrid load the data and save it in internal data and _index parameters. After that jqGrid change datatype option of jqGrid to "local". So all later sorting, filtering (searching) and paging of data will be done locally.

Sencha Touch Cannot call method 'substr' of null on Loacations:10

Hi as the Title says i am getting this error suddenly without changing anything.
This is the File Locations Code:
Ext.define('Wickelplaetze.store.Locations', {
extend: 'Ext.data.Store',
requires: 'Wickelplaetze.model.Location',
config: {
model: 'Wickelplaetze.model.Location',
storeId: 'locationsstore',
grouper: {
groupFn: function(record) {
return record.get('ort').substr(0, 1);
},
sortProperty: 'ort'
},
proxy: {
type: 'ajax',
url: 'http://freakp.com/wpapp/form-data.json',
withCredentials: false,
useDefaultXhrHeader: false
},
autoLoad: true
}
});
There are null values in you json for key ort. You can check if ort is not null and then return like -
if(record.get("ort")!= null){
return record.get('ort')[0];
}
Will remove that error doing so. But this will not sort records properly.
One more thing, if you want to sort list by first letter of ort , you can directly use -
return record.get("ort")[0];
When I tried your code to populate list, its actually running infinitely. I didn't get anything. Sorting these much values is damn slow. It took 3 mins to populate the list.
UPDATE
Link for working fiddle for your example. You can see null values at bottom of list. There are 7 null values for key ort.