1

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";
    }
}

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

You just need to call the ToString() method

Sample

SqlString i = ispravan;
string test = i.ToString();

Comments

1

Each SqlType has a Value property. This property gives you back the value of the SqlType cast to the native type.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.