Monday, October 12, 2009

Cross domain HTTP Request using JavaScript

My first choice was to use JQuery. You can use jQuery.ajax with dataType="jsonp". However, this won't work unless the servers supports jsonp (http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/). Cross domain HTTP requests are a really interesting topic.

After several tries, I decided to do this using ASP.NET (in the code-behind page):

Uri uri = new Uri("http://192.168.0.1/default/query");

if (uri.Scheme == Uri.UriSchemeHttp)

{

WebRequest request = HttpWebRequest.Create(uri);

request.Method = WebRequestMethods.Http.Get;

WebResponse response = request.GetResponse();

StreamReader reader = new StreamReader(response.GetResponseStream());

return reader.ReadToEnd();

}

Saturday, October 3, 2009

Filtering columns with NULL values in ADO.NET

In order to return columns with null values from a DataTable, use this expression:

"Isnull(Col1,'Null Column') = 'Null Column'"

If you need more information about filtering data, check out http://www.akadia.com/services/dotnet_filter_sort.html