In my application, I want to test the database connection to make sure
I can query it.  What is the preferred way to do this?  I have a
method that tries to query the User table and returns an ADOException
if it cannot get anything.  Is there a better way to do this?

-----------------
try
{
        var sessionFactory = CreateSessionFactory
(settings.DBConnectionString);
        using (var session = sessionFactory.OpenSession()) {
                var jobcodes = session.CreateCriteria(typeof(User));
        }
}
 catch (NHibernate.ADOException ex)
{
        System.Console.WriteLine(String.Format(@"Unable to connect to
database.  (Connection string: ""{0}"")",
settings.DBConnectionString));
}
----------------

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to