There are plenty resources you can find to answer your question (Well, at least that's what I think :D ).
Here's a start:
http://wiki.nhibernate.org/display/NH/Quick+Start+Guide
Or maybe you've been there? For me, it is a clear simple walkthrough into using NH.
O yea, configuring NH can be done programmatically. Here's an example:
Code:
this.AmetisConfiguration = new Configuration();
//Setting Configuration Properties
//*
IDictionary props = new Hashtable();
props["hibernate.connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
props["hibernate.dialect"] = "NHibernate.Dialect.MsSql2000Dialect";
props["hibernate.connection.driver_class"] = "NHibernate.Driver.SqlClientDriver";
props["hibernate.connection.connection_string"] = "Server=127.0.0.1;Initial Catalog=Lexica;User ID=sa;Password=;";
foreach( DictionaryEntry de in props )
{
this.AmetisConfiguration.SetProperty( de.Key.ToString(), de.Value.ToString() );
}
//*/
You'll need to set the appropriate value for the properties (well ... of course :D )