I am using SQL server time data type, I have made an sp which returns records from that table, But its throwing exception
'Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible''
I have checked the InnerException and its saying
'Input String was not in correct format'
When I run my query on SQL server its running fine below is the structure of my table
Id bigint
Name varchar(100)
timefrom time(0)
timeto time(0)
below is my sp
SELECT * FROM Table1 where condition
I am using NHibernate for data access
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;
}
its throwing exception on
var result = session.CreateSQLQuery("exec dbo.gen_GetData ?") .SetParameter(0, id) .List();