Hibernate Books

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: No Data being saved in the database please help _ I am new
PostPosted: Tue Sep 27, 2011 4:39 pm 
Newbie

Joined: Tue Sep 27, 2011 4:29 pm
Posts: 1
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>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.