Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7575047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:35:20+00:00 2026-05-30T16:35:20+00:00

I have in project simple connection to database: public static string GetConnectionString() { return

  • 0

I have in project simple connection to database:

public static string GetConnectionString()
        { 
            return @"Data Source=.\SQLEXPRESS;AttachDbFilename=" + HttpContext.Current.Request.PhysicalApplicationPath + "Application.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";            
        }

Now I try to implement NHibernate to project.

hibernate.cfg.xml here:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>        
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>    
    <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>  
    <property name="connection.connection_string">Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\1\Desktop\Application+\Application\Application.mdf;Integrated Security=True;User Instance=True</property>    
    <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>    
    <property name="show_sql">true</property>
  </session-factory>
</hibernate-configuration>

Test class “Clients” object here:

    public class Clients
    {
        private Guid id;
        private string name;
        private string phone;
        private string fax;
        private string email;
        private string address;
        private string contactPerson;

        public virtual Guid Id
        {
            get { return id; }
            set { id = value; }
        }

        public virtual string Phone
        {
            get { return phone; }
            set { phone = value; }
        }

        public virtual string Fax
        {
            get { return fax; }
            set { fax = value; }
        }

        public virtual string Email
        {
            get { return email; }
            set { email = value; }
        }

        public virtual string Address
        {
            get { return address; }
            set { address = value; }
        }

        public virtual string ContactPerson
        {
            get { return contactPerson; }
            set { contactPerson = value; }
        }

        public virtual string Name
        {
            get { return name; }
            set { name = value; }
        }
    }

Clients.hbm.xml here:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="WrapperObjects" namespace="WrapperObjects">  
  <class name="Clients" table="Clients" lazy="false">  
    <id name="Id" column="id">
      <generator class="native"></generator>
    </id>
    <property name="Name" column="name" type="System.String"/>
    <property name="Phone" column="phone" type="System.String"/>
    <property name="Fax" column="fax" type="System.String"/>
    <property name="Email" column="email" type="System.String"/>
    <property name="Address" column="address" type="System.String"/>
    <property name="ContactPerson" column="contactPerson" type="System.String"/>    
  </class>
</hibernate-mapping>

I used it like this:

public static void Configure()
        {            
            sessions = new Configuration().Configure().AddClass(typeof(Clients)).BuildSessionFactory();
        }

        public static void Insert(Clients pb)
        {            
            using (ISession session = sessions.OpenSession())            
            using (ITransaction tx = session.BeginTransaction())
            {                
                session.Save(pb);                
                tx.Commit();
            }
        }

On Configure() method appears an error: Keyword not supported.Parameter name: attachdbfilename
How fix??))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:35:21+00:00Added an answer on May 30, 2026 at 4:35 pm
    <?xml version="1.0" encoding="utf-8"?>
    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <session-factory>        
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>    
        <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>  
        <property name="connection.connection_string">Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\1\Desktop\Application+\Application\Application.mdf;Integrated Security=True;User Instance=True</property>    
        <property name="dialect">NHibernate.Dialect.MySQL5Dialect</property>    
        <property name="show_sql">true</property>
      </session-factory>
    </hibernate-configuration>
    

    Notice you are using the NHibernate.Driver.MySqlDataDriver driver_class and NHibernate.Dialect.MySQL5Dialect dialect, you need to change it to:

    <?xml version="1.0" encoding="utf-8"?>
    <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
      <session-factory>        
        <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle</property>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>    
        <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>  
        <property name="connection.connection_string">Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\1\Desktop\Application+\Application\Application.mdf;Integrated Security=True;User Instance=True</property>    
        <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property> 
        <property name="show_sql">true</property>
      </session-factory>
    </hibernate-configuration>
    

    I assumed you are using MSSQL 2008, change to NHibernate.Dialect.MsSql2005Dialect if you are using 2005

    https://community.jboss.org/wiki/DatabasesSupportedByNHibernate?_sscc=t

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a simple project where we read data from a socket and we
I have this simple test project just to test the IncludeExceptionDetailInFaults behavior. public class
Let's say I have two simple models project t.string :title vote t.references :project t.integer
I'm using JDBC for very simple database connectivity. I have created my connection/statement and
I have a simple two-field form that stores its data in the database. For
Im sure this will be a simple one but have a project that started
Hope you are fine. I have to make a Web Project (very simple) I
I'd like to try out the D programming language. I have simple pet project
I have a simple Scala project that runs without any problems inside Eclipse, however,
I have a very simple Setup project that copies three dlls into the GAC.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.