首页 新闻 会员 周边 捐助

关于iBatis net的异常:Unable to open connection to 。。。

0
悬赏园豆:30 [已解决问题] 解决于 2009-12-18 15:05

刚学iBatis,运行一个demo,抛出如下异常:

DataMapper Exception unhandled by user code

Unable to open connection to "Microsoft SQL Server, provider V1.0.5000.0 in framework .NET V1.1".

异常的详细描述是:

"An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

我用的是SqlServer2005+Visual studio 2008

是providers.config的问题吗?does not allow remote connections?我用的是本地数据库呀

providers.config的配置:

代码
<provider
name="sqlServer1.1"
description
="Microsoft SQL Server, provider V1.0.5000.0 in framework .NET V1.1"
enabled
="true"
default
="false"
assemblyName
="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass
="System.Data.SqlClient.SqlConnection"
commandClass
="System.Data.SqlClient.SqlCommand"
parameterClass
="System.Data.SqlClient.SqlParameter"
parameterDbTypeClass
="System.Data.SqlDbType"
parameterDbTypeProperty
="SqlDbType"
dataAdapterClass
="System.Data.SqlClient.SqlDataAdapter"
commandBuilderClass
="System.Data.SqlClient.SqlCommandBuilder"
usePositionalParameters
="false"
useParameterPrefixInSql
="true"
useParameterPrefixInParameter
="true"
parameterPrefix
="@"
allowMARS
="false"
/>

 

谢谢!

牛小花的主页 牛小花 | 初学一级 | 园豆:59
提问于:2009-12-11 14:46
< >
分享
最佳答案
0

看看这篇文章http://www.cnblogs.com/anderslly/archive/2007/09/29/ibatisinactionch03.html

 

name="sqlServer1.1" 好象不支持SQL2005吧

收获园豆:20
爱研究源码的javaer | 小虾三级 |园豆:930 | 2009-12-11 16:03
问题解决了,是我的数据库连接字符串不正确。出现这种问题,还是应该首先检查自己的数据库连接字符串,包括数据库的名称,用户名,密码等。 provider的配置是: <provider name="sqlServer2.0" enabled="true" description="Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0" //省略 />
牛小花 | 园豆:59 (初学一级) | 2009-12-18 15:08
其他回答(1)
1

<provider
   name="sqlServer1.1"
   description="Microsoft SQL Server, provider V1.0.5000.0 in framework .NET V1.1"
   enabled="false"
   assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
   connectionClass="System.Data.SqlClient.SqlConnection"
   commandClass="System.Data.SqlClient.SqlCommand"
   parameterClass="System.Data.SqlClient.SqlParameter"
   parameterDbTypeClass="System.Data.SqlDbType"
   parameterDbTypeProperty="SqlDbType"
   dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
   commandBuilderClass="System.Data.SqlClient.SqlCommandBuilder"
   usePositionalParameters="false"
   useParameterPrefixInSql="true"
   useParameterPrefixInParameter="true"
   parameterPrefix="@"
      allowMARS="false"
  />
<provider
    name="sqlServer2.0"
    enabled="true"
    description="Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0"
    assemblyName="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    connectionClass="System.Data.SqlClient.SqlConnection"
    commandClass="System.Data.SqlClient.SqlCommand"
    parameterClass="System.Data.SqlClient.SqlParameter"
    parameterDbTypeClass="System.Data.SqlDbType"
    parameterDbTypeProperty="SqlDbType"
    dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
    commandBuilderClass=" System.Data.SqlClient.SqlCommandBuilder"
    usePositionalParameters = "false"
    useParameterPrefixInSql = "true"
    useParameterPrefixInParameter = "true"
    parameterPrefix="@"
    allowMARS="false"
    />
  <provider
     name="sqlServer2005"
     enabled="true"
     default="true"
     description="Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0"
     assemblyName="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
     connectionClass="System.Data.SqlClient.SqlConnection"
     commandClass="System.Data.SqlClient.SqlCommand"
     parameterClass="System.Data.SqlClient.SqlParameter"
     parameterDbTypeClass="System.Data.SqlDbType"
     parameterDbTypeProperty="SqlDbType"
     dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
     commandBuilderClass=" System.Data.SqlClient.SqlCommandBuilder"
     usePositionalParameters = "false"
     useParameterPrefixInSql = "true"
     useParameterPrefixInParameter = "true"
     parameterPrefix="@"
     allowMARS="true"
    />

收获园豆:10
kenzhang | 园豆:165 (初学一级) | 2009-12-11 17:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册