Reputation: 47
This works but I want to convert SqlString
to String
and do String.Length
. If String.Length
is e.g. 5, I want to display in cell (in table in SQL Server) e.g. Active, but if not, I want to display the current field value.
public class proveraMb
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString matbr (SqlString ispravan)
{
SqlString i = ispravan;
if (i == "ss")
return i;
else
return "nije dobar";
}
}
Upvotes: 1
Views: 2708
Reputation: 1698
Each SqlType
has a Value
property. This property gives you back the value of the SqlType
cast to the native type.
Upvotes: 1
Reputation: 48806
While the ToString()
method does work, it is better to use (and get used to using) the Value
property. The reason that this is better is that all Sql*
types have a Value
property that returns the expected native .NET type. So SqlInt64.Value
returns a long
, SqlDateTime.Value
returns a DateTime
, etc.
Upvotes: 3
Reputation: 7179
You just need to call the ToString() method
Sample
SqlString i = ispravan;
string test = i.ToString();
Upvotes: 1