I am trying to use User-Defined-Data Type with C # and SQL Server 2008, but I have an exception that occurs when the command is executed. ExecuteReader ().
string qyery = "SELECT * FROM Product WHERE IsAvailableProduct < @Param"; SqlCommand command = new SqlCommand(qyery, conn); SqlParameter param = new SqlParameter("@Param", SqlDbType.Structured); param.UdtTypeName = "MyBolean"; param.SqlDbType = SqlDbType.Structured; param.Value = 1; command.Parameters.Add(param); SqlDataReader reader = command.ExecuteReader();
Raised Exception:
Failed to convert parameter value from a Int32 to a IEnumerable``1.
What is wrong in my code?
EDIT :
If I change SqlDbType to Udt , I have this exception: Specified type is not registered on the target server.System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
If I set the DbType property as Int (which is the base type "MyBolean"), the result is a Failed to convert parameter value from a Int32 to a IEnumerable exception Failed to convert parameter value from a Int32 to a IEnumerable 1., too.
EDIT :
I changed the name because in SQL Server 2008 it is "User Define DATA Type" and "User Defined Types"
source share