【发布时间】:2013-03-13 07:10:45
【问题描述】:
我正在使用 SQL 服务器时间数据类型,我制作了一个从该表返回记录的 sp, 但它抛出异常
'Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible''
我已经检查了 InnerException 及其说法
'Input String was not in correct format'
当我在 SQL 服务器上运行查询时,它运行良好 下面是我的表结构
Id bigint
Name varchar(100)
timefrom time(0)
timeto time(0)
下面是我的sp
SELECT * FROM Table1 where condition
我正在使用 NHibernate 进行数据访问
public System.Collections.IList GetData(long id)
{
string connectionStr = ConfigurationManager.ConnectionStrings["FNHConnection"].ConnectionString;
IDbConnection conn;
conn = new SqlConnection(connectionStr);
conn.Open();
ISessionFactory sessionFactor = HibernateTemplate.SessionFactory;
ISession session = sessionFactor.OpenSession(conn);
var result = session.CreateSQLQuery("exec dbo.gen_GetData ?")
.SetParameter(0, id)
.List();
return result;
}
它在
上抛出异常var result = session.CreateSQLQuery("exec dbo.gen_GetData ?") .SetParameter(0, id) .List();
【问题讨论】:
标签: c# sql-server