两张表,表一:
CREATE TABLE [dbo].[PB_Users](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserCode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
[UserName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[PassWord] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[Description] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
[RegUserId] [int] NULL,
[RegDate] [datetime] NULL CONSTRAINT [DF_PB_Users_RegDate] DEFAULT (getdate()),
[IfDelete] [bit] NULL CONSTRAINT [DF_PB_Users_IfDelete] DEFAULT ((0)),
[TimeStamp] [timestamp] NULL,
[UpdateUserId] [int] NULL,
[UpdateDate] [datetime] NULL,
[UserGroupId] [int] NULL,
CONSTRAINT [PK_PB_Users] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]与表二:
CREATE TABLE [dbo].[PB_Usergroups](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserGroupCode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
[UserGroupName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[Description] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
[RegUserId] [int] NULL,
[RegDate] [datetime] NULL CONSTRAINT [DF_PB_Usergroups_RegDate] DEFAULT (getdate()),
[IfDelete] [bit] NULL CONSTRAINT [DF_PB_Usergroups_IfDelete] DEFAULT ((0)),
[TimeStamp] [timestamp] NULL,
[UpdateUserId] [int] NULL,
[UpdateDate] [datetime] NULL,
CONSTRAINT [PK_PB_Usergroups] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
对应IBATISNET中的MAP配置文件如下:<sqlMap namespace="PB_Usergroups" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <alias>
<typeAlias alias="PB_Usergroups" type="Model.PB_Usergroups,Model" />
</alias>
<resultMaps>
<resultMap id="SelectAllResult-PB_Usergroups" class="PB_Usergroups" >
<result property="Id" column="Id" />
<result property="UserGroupCode" column="UserGroupCode" />
<result property="UserGroupName" column="UserGroupName" />
<result property="Description" column="Description" />
<result property="RegUserId" column="RegUserId" />
<result property="RegDate" column="RegDate" />
<result property="IfDelete" column="IfDelete" />
<result property="UpdateUserId" column="UpdateUserId" />
<result property="UpdateDate" column="UpdateDate" />
</resultMap>
</resultMaps>
。。sqlmap.config文件配置如下:
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <!-- Rem : If used via a DataAccess context, properties tag will be ignored >-->
<properties resource="database.config"/>
<!--<properties embedded="database.config,IBatisNetDataAccess"/>-->
<settings>
<setting useStatementNamespaces="${useStatementNamespaces}"/>
<setting cacheModelsEnabled="true"/>
<setting validateSqlMap="true"/>
</settings> <!-- Optional if resource -->
<!--<providers embedded="providers.config,IBatisNetDataAccess"/>-->
<providers resource="providers.config"></providers>
<!-- ==== SqlClient configuration ========= -->
<!-- Rem : If used via a DataAccess context, database tag will be ignored -->
<database>
<!-- Optional ( default ) -->
<provider name="sqlServer2.0"/>
<dataSource name="iBatisNet" connectionString="data source=${datasource};database=${database};user id=${userid};password=${password};connection reset=false;connection lifetime=5; min pool size=1; max pool size=50"/>
</database> <sqlMaps >
<sqlMap resource="Map/SqlClient/PB_Usergorups.xml"></sqlMap>
<sqlMap resource="Map/SqlClient/PB_Users.xml"> </sqlMap>
</sqlMaps>
</sqlMapConfig>
结果只有一个WEB页面能正确访问数据,就是上面的那张表能访问,下面给出MAP里的配置文件的表,以及它所对应的WEB页面不能访问到数据,总是显示下错误:UserGroupId
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IndexOutOfRangeException: UserGroupId堆栈跟踪:
[IndexOutOfRangeException: UserGroupId]
System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +66
System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +104
IBatisNet.DataMapper.TypeHandlers.Nullables.NullableInt32TypeHandler.GetValueByName(ResultProperty mapping, IDataReader dataReader) +23
IBatisNet.DataMapper.Configuration.ResultMapping.ResultProperty.GetDataBaseValue(IDataReader dataReader) +32
IBatisNet.DataMapper.MappedStatements.PropertyStrategy.DefaultStrategy.Set(RequestScope request, ResultMap resultMap, ResultProperty mapping, Object& target, IDataReader reader, Object keys) +244
IBatisNet.DataMapper.MappedStatements.ResultStrategy.ResultMapStrategy.Process(RequestScope request, IDataReader& reader, Object resultObject) +287
IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForList(RequestScope request, IDalSession session, Object parameterObject, Int32 skipResults, Int32 maxResults, RowDelegate`1 rowDelegate) +436
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForList(IDalSession session, Object parameterObject, Int32 skipResults, Int32 maxResults) +111
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForList(IDalSession session, Object parameterObject) +63
IBatisNet.DataMapper.SqlMapper.QueryForList(String statementName, Object parameterObject) +183
FA.DataAccess.PB_UsergroupsAccess.GetAllUsergroups() in C:\My Documents\Visual Studio 2005\Projects\FloodAlarm\FA.DataAccess\FA.DataAccess\PB_UsergroupsAccesss.cs:15
Default2.InitBind() +33
Default2.Page_Load(Object sender, EventArgs e) +21
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +43
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3750 请高手指点;谢谢!
CREATE TABLE [dbo].[PB_Users](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserCode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
[UserName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[PassWord] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[Description] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
[RegUserId] [int] NULL,
[RegDate] [datetime] NULL CONSTRAINT [DF_PB_Users_RegDate] DEFAULT (getdate()),
[IfDelete] [bit] NULL CONSTRAINT [DF_PB_Users_IfDelete] DEFAULT ((0)),
[TimeStamp] [timestamp] NULL,
[UpdateUserId] [int] NULL,
[UpdateDate] [datetime] NULL,
[UserGroupId] [int] NULL,
CONSTRAINT [PK_PB_Users] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]与表二:
CREATE TABLE [dbo].[PB_Usergroups](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserGroupCode] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
[UserGroupName] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
[Description] [nvarchar](100) COLLATE Chinese_PRC_CI_AS NULL,
[RegUserId] [int] NULL,
[RegDate] [datetime] NULL CONSTRAINT [DF_PB_Usergroups_RegDate] DEFAULT (getdate()),
[IfDelete] [bit] NULL CONSTRAINT [DF_PB_Usergroups_IfDelete] DEFAULT ((0)),
[TimeStamp] [timestamp] NULL,
[UpdateUserId] [int] NULL,
[UpdateDate] [datetime] NULL,
CONSTRAINT [PK_PB_Usergroups] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
对应IBATISNET中的MAP配置文件如下:<sqlMap namespace="PB_Usergroups" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <alias>
<typeAlias alias="PB_Usergroups" type="Model.PB_Usergroups,Model" />
</alias>
<resultMaps>
<resultMap id="SelectAllResult-PB_Usergroups" class="PB_Usergroups" >
<result property="Id" column="Id" />
<result property="UserGroupCode" column="UserGroupCode" />
<result property="UserGroupName" column="UserGroupName" />
<result property="Description" column="Description" />
<result property="RegUserId" column="RegUserId" />
<result property="RegDate" column="RegDate" />
<result property="IfDelete" column="IfDelete" />
<result property="UpdateUserId" column="UpdateUserId" />
<result property="UpdateDate" column="UpdateDate" />
</resultMap>
</resultMaps>
。。sqlmap.config文件配置如下:
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <!-- Rem : If used via a DataAccess context, properties tag will be ignored >-->
<properties resource="database.config"/>
<!--<properties embedded="database.config,IBatisNetDataAccess"/>-->
<settings>
<setting useStatementNamespaces="${useStatementNamespaces}"/>
<setting cacheModelsEnabled="true"/>
<setting validateSqlMap="true"/>
</settings> <!-- Optional if resource -->
<!--<providers embedded="providers.config,IBatisNetDataAccess"/>-->
<providers resource="providers.config"></providers>
<!-- ==== SqlClient configuration ========= -->
<!-- Rem : If used via a DataAccess context, database tag will be ignored -->
<database>
<!-- Optional ( default ) -->
<provider name="sqlServer2.0"/>
<dataSource name="iBatisNet" connectionString="data source=${datasource};database=${database};user id=${userid};password=${password};connection reset=false;connection lifetime=5; min pool size=1; max pool size=50"/>
</database> <sqlMaps >
<sqlMap resource="Map/SqlClient/PB_Usergorups.xml"></sqlMap>
<sqlMap resource="Map/SqlClient/PB_Users.xml"> </sqlMap>
</sqlMaps>
</sqlMapConfig>
结果只有一个WEB页面能正确访问数据,就是上面的那张表能访问,下面给出MAP里的配置文件的表,以及它所对应的WEB页面不能访问到数据,总是显示下错误:UserGroupId
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IndexOutOfRangeException: UserGroupId堆栈跟踪:
[IndexOutOfRangeException: UserGroupId]
System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName) +66
System.Data.SqlClient.SqlDataReader.GetOrdinal(String name) +104
IBatisNet.DataMapper.TypeHandlers.Nullables.NullableInt32TypeHandler.GetValueByName(ResultProperty mapping, IDataReader dataReader) +23
IBatisNet.DataMapper.Configuration.ResultMapping.ResultProperty.GetDataBaseValue(IDataReader dataReader) +32
IBatisNet.DataMapper.MappedStatements.PropertyStrategy.DefaultStrategy.Set(RequestScope request, ResultMap resultMap, ResultProperty mapping, Object& target, IDataReader reader, Object keys) +244
IBatisNet.DataMapper.MappedStatements.ResultStrategy.ResultMapStrategy.Process(RequestScope request, IDataReader& reader, Object resultObject) +287
IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForList(RequestScope request, IDalSession session, Object parameterObject, Int32 skipResults, Int32 maxResults, RowDelegate`1 rowDelegate) +436
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForList(IDalSession session, Object parameterObject, Int32 skipResults, Int32 maxResults) +111
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForList(IDalSession session, Object parameterObject) +63
IBatisNet.DataMapper.SqlMapper.QueryForList(String statementName, Object parameterObject) +183
FA.DataAccess.PB_UsergroupsAccess.GetAllUsergroups() in C:\My Documents\Visual Studio 2005\Projects\FloodAlarm\FA.DataAccess\FA.DataAccess\PB_UsergroupsAccesss.cs:15
Default2.InitBind() +33
Default2.Page_Load(Object sender, EventArgs e) +21
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +43
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3750 请高手指点;谢谢!
解决方案 »
- 怎么动态跳转到另一个页面?
- 关于在线Word编辑的。求指点。
- 为什么我每次点击树形结构上的节点就会触发"Session_Start"事件啊?
- 局域网MS SQL Server2000
- 请教一个简单的xsl的问题
- 一个新手问题啊,asp.net2.0怎么没有dll文件
- 我想清空visual studio.net中的最近项目列表,怎么做?
- 有关购物车的效果。(主要是显示方面的特效)
- EXCEL导入到DATASET必须将文件打开吗?
- 怎样将.txt文本用asp.net程序写入SQLSERVER 数据库中
- 求JS或Jquery实现的类似Excel选择多个单元格的效果
- 在asp.net中怎样用js传参,执行后台方法,最好ajax方式,但是我对这种不熟悉,希望有个简单的案例
·详情请访问:http://www.515dns.com
<sqlMap resource="Map/SqlClient/PB_Users.xml"> </sqlMap>
应该先缩小到是PB_Usergorups.xml的错误还是PB_Users.xml的错误另外真的很不喜欢ibatis
现在的技术就是一团乱麻