0

when i try to convert the SqlByte datatype to byte like this:

    SqlByte x = 2;
    int y;
    y = Convert.ToInt32(x);

this exeptions happens: Unable to cast object of type 'System.Data.SqlTypes.SqlByte' to type 'System.IConvertible.

how can convert it?

2 Answers 2

2

The equivalent type of a SqlByte is a Byte. Hence you can't convert it to an Int32.

Furthermore the actual connection is the following:

  • The Sql Server Data Type is tinyint.
  • The CLR data type (SQL Server) is SqlByte
  • The CLR data type (.NET Framework) is Byte
Sign up to request clarification or add additional context in comments.

Comments

1

Try:

SqlByte x = 2;
int y;
y = (int) x;

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.