Thursday, February 18, 2016

Dynamic sql returns int instead of resultset

I had to create a stored procedure that was created dynamically. It so happened that when I tested it in SQL server, it ran, producing the results. When I implemented in and called it from a stored procedure, the return value was an int. After googling, i found a solution that worked. I had to create the stored procedure to produce similar results then import in into the application. Then, I went back and edited it to return the results that I wanted it to produce.

I found the trick here: http://www.techdreams.org/microsoft/fixing-linq-to-sql-issue-stored-procedure-definition-returns-int-instead-of-resultset-2/2752-20090614


Unable to cast object of type 'Data' to type 'System.IConvertible'

I came upon this error when developing an application. I was using a foreach loop to dynamically create a select list. It so happened that I was not looping on the result without point to value in it.


So instead of just using @y i had to use @y.name in the select option