please see below for the Files and the code which I have .
I am trying to save the data to the database through mapping.
The system do not throw any error message nor the data is being written to the database so no clue whats going on.
please help me . I am new to the programming and also Nhibernate
Code:
namespace zam.WebPages
{
public partial class SuperUserLogin1 : System.Web.UI.Page
{
protected void AddUser_Click(object sender, EventArgs e)
{
try
{
// setup nhibernate configuration
NHibernate.Cfg.Configuration config = new NHibernate.Cfg.Configuration();
// add our assembly
//config.AddXmlFile(@"C:\Documents and Settings\Keycorp\My Documents\Visual Studio 2008\Projects\zam\zam\Mappings\superuser.hbm.xml");
config.AddAssembly("zam");
// setup nhibernate session
NHibernate.ISessionFactory factory = config.BuildSessionFactory();
NHibernate.ISession session = factory.OpenSession();
// start nhibernate transaction
NHibernate.ITransaction transaction = session.BeginTransaction();
// create contact
testlogin1 superUserLogin = new testlogin1();
superUserLogin.userID = UserID.Text;
superUserLogin.userName = UserName.Text;
superUserLogin.password = passwrod.Text;
// Tell NHibernate that this object should be saved
session.Save(superUserLogin);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
}
catch (Exception m )
{
System.Console.WriteLine(m);
}
}
}
}
hbm.user.file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="zam" namespace="zam.WebPages">
<class name="zam.testlogin1, zam " table="superuser">
<id name="userID">
<generator class="identity"/>
</id>
<property name="userNAME " />
<property name="password " />
</class>
</hibernate-mapping>
code behind file
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace zam
{
public class testlogin1
{
public string userID
{
get;
set;
}
public string userName
{
get;
set;
}
public string password
{
get;
set;
}
}
}
my config file
Code:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<section name="hibernate-configuration" requirePermission="false" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" /> -- this is in the config sections of web.config file
<session-factory name="NHibernate.Test">
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
<property name="connection.connection_string">
Database=zam;Data Source=localhost;User Id=root;Password=
</property>
<property name="dialect">NHibernate.Dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>