vendredi 22 octobre 2010

jQuery Autocomplete : set autocomplete field to a value

I struggled to find this and the solution is so simple…

In the select event, you can set the value of the field and if you return false, the value won’t be the selected item.

 $(function() {
$("input#ZipCode").autocomplete({
source: function(request, response) {
$.ajax({
url: '<%= Url.Action("ZipCodeAutoComplete", "Home", new { area = "" }) %>',
data: { term: request.term },
success: function(data) {
response($.map(data, function(item) {
return { label: item.ZipCodel + " - " + item.City, ZipCode: item.ZipCodel, City: item.City }
}))
}
})
},
minLength: 3,
select: function(event, ui) {
$("#City").val(ui.item.Ville);
$("#ZipCode").val(ui.item.ZipCode);
return false;
}
});
});

jeudi 21 octobre 2010

Connect to Oracle using NHibernate

Here is my setup to connect to an Oracle database using the ODP.NET provider.

Install Oracle client v9 R2 or greater.

Reference Oracle.DataAccess dll in your project.

Configure your database connection in the tnsnames.ora file. This file is located in $ORACLE_HOME/network/admin/tnsnames.ora.

Configure your connection string in your application. I usually use this syntax:

<add name="default" connectionstring="Data Source=tnsnames_alias;User ID=username;Password=pwd">

Then use the OracleDataClientDriver in your NHibernate configuration or OracleDataClientConfiguration if you use FluentNHibernate.


This should do it!