TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
benzema kirism
NA
30
0
Can not retrieve data from Database
Jun 10 2010 7:20 AM
Hi all.
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:
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
...
</configSections>
<!--NHibernate Configuration-->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
<property name="dialect">
NHibernate.Dialect.MsSql2005Dialect
</property>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=codix;
Database=NhibernateTest;
Integrated Security=True;
</property>
</session-factory>
</hibernate-configuration>
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 :
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NhibernateTest.UserName, NhibernateTest" table="UserName">
<id name="PersonID" column="PersonID" type="Int32" length="4">
<generator class="identity" />
</id>
<property name="Email" column= "Email" type="String" length="50"/>
<property name="Password" column= "Password" type="String" length="50"/>
<property name="status" column= "status" type="String" length="50"/>
<property name="DateTime" column= "DateTime" type="DateTime"/>
</class>
</hibernate-mapping>
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
Attachment:
NhibernateTest.zip
Reply
Answers (
1
)
Asp.Net with C#: How to download file from Server
Adding scrollbars in groupbox which is inside a panel