cast string to long

  • Thread starter Thread starter mp
  • Start date Start date
M

mp

How do i cast a string from sql to a long? lDocumentVersion is long,
oSqlDR.GetValue(0) returns a string.



lDocumentVersion =oSqlDR.GetValue(0);



Thanks
 
How do i cast a string from sql to a long? lDocumentVersion is long,
oSqlDR.GetValue(0) returns a string.

lDocumentVersion =oSqlDR.GetValue(0);

You can't cast it but you can convert it. Use Convert.ToInt64(string)
overload. Check for null first if that is a possible value. Or if you
want more control, use one of the overloads of Int64.Parse.
 
Back
Top