i am using Nhibernate to mapping from object class to table database . but i have trouble to get data from database in which i can not display data.
the following step configured to run Nhibernate.
Reference my project to Nhibernate.dell,log4net.dll.
Making web.config as follow:
...
NHibernate.Dialect.MsSql2005Dialect
NHibernate.Connection.DriverConnectionProvider
NHibernate.Driver.SqlClientDriver
Server=codix;
Database=NhibernateTest;
Integrated Security=True;
and i have class to mapping look like that :
namespace NhibernateTest
{
public class UserName
{
private int personID;
private string email;
private string password;
private bool status;
private DateTime dateCreated;
// Defining properties
public virtual int PersonID
{
get { return personID; }
set { personID = value; }
}
public virtual string Email
{
get { return email; }
set { email = value; }
}
public virtual string Password
{
get { return password; }
set { password = value; }
}
public virtual bool Status
{
get { return status; }
set { status = value; }
}
public virtual DateTime DateCreated
{
get { return dateCreated; }
set { dateCreated = value; }
}
}
}
xml mapping file :
in the main page i write on load event :
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddAssembly("NhibernateTest");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
// User tam = new User();
// it is not call UserName class
IList lstuser = session.CreateCriteria(typeof(UserName)).List();
GridView1.DataSource = lstuser;
GridView1.DataBind();
session.Close();
when i run the main page that it is no present everything.
Is that configure error something occurs from web.config file.
Please give me recommendation how to correct it.
thanks and best regards
Abhimanyu K VatsaPosted Jun 14, 2010, 4:23 AM
Your question is too long....as if you want to connect ur application to database then look at this article
http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/1591/
As if you want to connect it to XML file then look at this article
http://www.vbdotnetheaven.com/UploadFile/abhikumarvatsa/1569/
I hope my post will help you to solve out your problem. Good Luck