Insert chinese using odata client to azure sql - sql

I am using azure aql as a backend for a windows phone app I am writing. I expose the db using odata protocol, and using the odata client library to read and write db. I am having a problem to insert Chinese strings. Each chinese charatcter will show up as "?" in the db.
The following is the code. Using the debugger, i can tell, the chinese character is still in the write format before the BeginSaveChanges call. The according field in the db is defined as nvarchar. I can put chinese no problem from the web management portal.
NewJoke.Title = Regex.Replace(NewJoke.Title, "'", "''");
NewJoke.Content = Regex.Replace(NewJoke.Content, "'", "''");
dsc = new DataServiceContext(funnyJokesUri);
try
{
//Name of the entity goes into the first attribute of the AddObject method followed by the entity itself
//INSERTING
dsc.AddObject("Jokes", NewJoke);
dsc.BeginSaveChanges(insertJoke_Completed, dsc);
}

You have to set the collation for Chinese on the column, I think. More... http://blogs.msdn.com/b/sqlazure/archive/2010/06/11/10023650.aspx
BTW -- I wasn't clear on reading your question -- it sounds like you're saying the db stores the chinese fine when you use the web portal to insert it; but presumably, it does not store the chinese when you use some other method for inserting it. (?) Is that what you're saying?

Related

ms sql connection string with semi colon in password failing to connect

Am working on anypoint studio 6.6.8 with runtime 3.9.4EE.
I have the following mssql generic database connection string.
jdbc:sqlserver://ABC.org:59000;databaseName=master;username=nrp;password=*37n%3b#wu;5r:;_1z~(f{1y{j
Test connection gives me the following error:
Test connection failed:
org.mule.module.db.internal.domain.connection.ConnectionCreationException: Cannot get connection for URL jdbc:sqlserver://ABC.org:59000;databaseName=master;username=nrp;password=<<credentials>>;5r:;_1z~(f{1y{j: The connection string contains a badly formed name or value
PS: I have 2 semi colons in password
I have seen similar question raised here earlier a few times, hence my question might look repetitive.
however I tried the following solutions given in the replies. none of them worked. Please let me know if you have any alternate solution.
Enclosing the password in single quotes.
adding \ in front of ;
Enclosing password within double quotes or {}
Am not the admin hence removing ; from password cannot be done.
The connection string is in a format known as JAVA JDBC URL. It is similar to a normal URL. Many characters are not allowed in URLs and have to be encoded with the URL encoding method. Try using URL encoding for the entire URL. You can do it with most languages or online pages, though you might want to avoid public pages for sensitive information like passwords.
Example in Groovy: https://stackoverflow.com/a/10187493/721855.
Example in Python: https://stackoverflow.com/a/5607708/721855.
Thank you #aled
So the {} did work. I was doing it the wrong way.
I was encrypting the password & later concatenating {} to the decrypted password right b4 passing the connection string.
What worked was that I enclosed the password in {} first & then encrypted it.

How to pass Azure Storage connection string to Container Instance

I have an application that uses Azure Storage Tables that I would like to run in an Azure Container Instance. The Container Instance environment variables (my only option for passing configuration to the application running in the container) only allow alphanumeric and underscores in the quoted string values, and a connection string has things like semicolons and equals. I thought a Key Vault would work, but then I can't pass an application ID either. I can't pass:
Connection String
URL
AppID - UUID
base64 data
The only thing I can even think of would be to encode these strings to bytes (UTF-8) and convert the bytes to a hex string, but that's a messy workaround. What is the recommended means of passingconfiguration to an Azure Container Instance?
Update 11/6: We've updated the Azure portal to be more lenient on env var input so strings with special characters like connection strings should work now. Thanks!
This is currently a constraint of the Azure portal. Please try this deployment via az cli, which should support special characters in env var values.

Replace a String in Custom Connect To Statement in qlikview

I am using a REST Connector in Qlikview and i need to pass a variable to the CUSTOM CONNECT TO Statement when connecting to a Web Service.
CUSTOM CONNECT TO "Provider=QVRestConnector.exe;url="http://test.example.com?auth=2334342assa13"
Now, instead of the auth token directly getting passed, i need to provide it at the RunTime. I tried the below but its not working.
Let vToken="a3122423421f";
"Provider=QVRestConnector.exe;url="http://test.example.com?auth=$(vToken)"
Try to replace
Let vToken="a3122423421f";
With
Let vToken='a3122423421f';
A string in QlikView is defined with the ' character, " represents for instance field names.

How to add new row to a sharepoint list in objective c?

I tried using updatelistitems web service of the sharepoint. but could not find how to give the input data in the xml format along with the soap request.
Thanks in advance
Since it's an integration you are doing I'd recommend using an ADO.NET adapter for SharePoint and connect through a WCF service (soap/wsdl). It will save you a lot of time and if done correctly your integration wont be proprietary.
Check this ready-made wcf service, http://www.bendsoft.com/downloads/camelot-wcf-service/, installation instructions here http://blog.bendsoft.com/category/integrations/wcf-services/.
It's open source but ships with support for the Camelot XML format, which bundles the schema along with the content if you query for data, check the example schema here http://www.bendsoft.com/downloads/sharepoint-web-parts/xml-pusher/.
To insert data into SharePoint with the WCF service you can simply do something like this
$SharePointNonQuery = new SharePointNonQuery(array(
'sql' => "INSERT INTO contactform (title,email,company,message) VALUES ('John Doe','john.doe#example.com','Johns Company','A test message!')",
'method' => 'ExecuteNonQuery',
'connString' => 'sharepoint_connection',
'sharedKey' => constant("WSDL_SHARED_KEY")
));
The example is obviously made in PHP ( http://blog.bendsoft.com/2011/04/camelot-php-tools-1-1-for-sharepoint-released/ ) but it's equally easy to create a class in Objective-C and send your command as SQL via SOAP and execute the SQL command in the WCF service.
Hope this helps!
----------- Edits below this line -----------
Querying the suggested WCF service from Objective-C would result in something like this
WSMethodInvocationRef soapReq = createSOAPRequest(url, method, namespace, params, paramOrder, reqHeaders);
The Url is the location of the wcf service, ie. http://yourserver.com/wcf/camelot.wcf
The method is the method IN the wcf service you want to use. The Camelot WCF service have a few default methods. Suitable in this scenario would be the ExecuteNonQuery method which takes the following arguments; sql, connString and sharedKey.
bool ExecuteNonQuery(string sql, string connString, string sharedKey);
The params is the arguments listed above, they should be sent as an associative array (NSDictionary I assume).
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
#"INSERT INTO YourList (title,email,company,message) VALUES ('John Doe','john.doe#example.com','Johns Company','A test message!')", #"sql",
#"connString", #"SharePointConnectionString",
#"sharedKey", #"YourPreferredKey",
nil];
The ExecuteNonQuery is a bool method it will return true or false to the soapReq method in the Objective-C application.

Can Flash be integrated with SQL?

Can Flash be used together with SQL? I have a Flash form and I need to connect it to SQL. If there is any example on the net about this topic. I can't find it.
You don't use ActionScript directly with an SQL database. Instead you make http requests from ActionScript to a server, specifying the correct parameters. A typical opensource setup, is a PHP script communicating with a MySQL DB, but you can use Java with Oracle, Ruby with CouchDB, .NET with SQL or any other possible configuration. The important point is that you must be able to call a server script and pass variables... typically a Restful setup.
Once your PHP script has been properly configured, you can use http POST or http GET to send values from ActionScript.
PHP:
<?php
$updateValue = $_POST["updateValue"];
$dbResult = updateDB( $updateValue ); //This should return the db response
echo( $dbResult );
?>
To call this script from ActionScript, you need to create a variables object.
var variables:URLVariables = new URLVariables();
variables.updateValue = "someResult";
The variable name .updateValue, must match the php variable exactly.
now create a URLRequest Object, specifying the location of your script. For this example the method must be set to POST. You add the variable above to the data setter of the request.
var request:URLRequest = new URLRequest( "yourScript.php" );
request.method = URLRequestMethod.POST;
request.data = variables;
Now create a URLLoader and add an event listener. Do not pass the request created above to the constructor, but to the load method.
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onComplete );
loader.load( request );
The handler would look something like this.
private function onComplete( e:Event ) : void
{
trace( URLLoader( e.target ).data.toString() );
}
This example shows how to update and receive a response from a server / db combo. However, you can also query a DB through the script and parse the result. So in the PHP example above, you can output JSON, XML or even a piped string, and this can be consumed by ActionScript.
XML is a popular choice, as ActionScript's e4x support treats XML like a native object.
To treat the response above like an XML response, use the following in the onComplete handler.
private function onComplete( e:Event ) : void
{
var result:XML = XML( URLLoader( e.target ).data );
}
This will throw an error if your xml is poorly formed, so ensure the server script always prints out valid XML, even if there is a DB error.
The problem with this is giving someone a flash file that directly accesses SQL server is very insecure. Even if it's possible, which I have seen SOCKET classes out there to do so for MySQL (though never used it), allowing users to remotely connect to your DB is insecure as the user can sniff the login information.
In my opinion, the best way to do this is to create a Client/Server script. You can easily do this with PHP or ASP.net by using SendAndLoad to send the data you need to pass to SQL via POST fields. You can then send back the values in PHP with:
echo 'success='.+urlencode(data);
With this, flash can access the data via the success field.
I don't personally code flash but I work with a company who develops KIOSK applications for dozens of tradeshow companies, and my job is to store the data, return it to them. This is the method we use. You can make it even cleaner by using actual web services such as SOAP, but this method gets the job done if its just you using it.
You should look into Zend Amf or even the Zend Framework for server side communication with Flash. As far as I know Zend Amf is the fastest way to communicate with PHP ( therefore your database ) also you can pass & return complex Objects from the client to the server and vice versa.
Consider this , for instance. You have a bunch of data in your database , you implement functions in ZF whereas this data is formatted and set as a group of Value Objects. From Flash , you query ZF , Zf queries the database , retrieve & formats your data, return your Value Objects as a JSON string ( for instance ). In Flash, you retrieve you JSON string , decode it and assign your Value Objects to whatever relevant classes you have.
There are plenty of tutorials out there regarding Flash communication with the Zend Framework.
Here's an example:
http://gotoandlearn.com/play.php?id=90