错误的连接字符串的NHibernate 3.3 [英] Wrong connection string NHibernate 3.3

查看:264
本文介绍了错误的连接字符串的NHibernate 3.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何利用编写NHibernate的正确连接字符串SQL Server 2012的?

How to write correct connection string for Nhibernate using SQL Server 2012?

如果我也写数据库的名字吗?

Should I write also database name?

错误:
我得到错误的初始目录的错误

Error: I get error with wrong „initial catalog"

有关NHibernate的错误连接字符串(复制我从我的服务器此连接字符串):

Wrong connection string for NHibernate (I copy this connection string from my server):

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSqlCeDialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlServerCeDriver</property>
    <property name="connection.connection_string">Data Source=RAFAL-KOMPUTER\MSSQLSERVER4;Initial Catalog=rafal;Integrated Security=True</property>
    <property name="show_sql">true</property>
  </session-factory>
</hibernate-configuration>

我复制连接字符串从这一部分:

I copy connection string from this part:

我也想这一点,但没有帮助。

I am trying also this but does not help.

<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
    <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
    <property name="connection.connection_string">Data Source=RAFAL-KOMPUTER\MSSQLSERVER4;Initial Catalog=rafal;Integrated Security=True</property>

我不`吨知道如何正确配置的 SQL Server 2012中

推荐答案

第一个片断不应该工作,而司机是CE(精简版)。

The first snippet should not work, while the driver is for CE (Compact edition).

第二个看起来更好,甚至更是为我工作。 (详见这里 http://www.connectionstrings.com/sql-server-2012 )。最重要的,是要有提供程序名称的正确的设置(点击此处查看: http://stackoverflow.com/a/8150792/ 315850 )。试试这个调整的片段(只是要确保所有部件都设置正确)

The second one looks better, and even more it is working for me. (see more here http://www.connectionstrings.com/sql-server-2012). The most important thing, is to have correct settings of the Provider name (check here: http://stackoverflow.com/a/8150792/315850). Try this adjusted snippet (just to be sure that all parts are set correctly)

<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<!-- to profit from features in 2012, use its dialect -->
<property name="dialect">NHibernate.Dialect.MsSql2012Dialect</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<!-- the simplest connection string -->
<property name="connection.connection_string">Data Source=RAFAL-KOMPUTER\MSSQLSERVER4;Database=rafal;Trusted_Connection=True;</property>

我们必须确保正确的驱动程序使用(不符合CE或任何其他则 NHibernate.Driver.SqlClientDriver 这意味着 System.Data这。 SqlClient中

We have to be sure that correct driver is used (not CE or any other then NHibernate.Driver.SqlClientDriver which means System.Data.SqlClient)

仔细检查你1)SQL Server和命名实例为: RAFAL-电脑服务\\ MSSQLSERVER4 2)的数据库名称为:拉法尔 3)登录有权访问它,这必须努力

Double check that your 1) SQL server and named instance is: RAFAL-KOMPUTER\MSSQLSERVER4 and 2) the Database name is: rafal and 3) your login has access rights to it, this must work

这篇关于错误的连接字符串的NHibernate 3.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆