• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 809
  • Last Modified:

How to get bigint from database in C#?

This code in C# doesnt work.. it crashes ... playerid does have a value in the database.. and it is a bigint


long playerid;
playerid = (long)pRS.Fields["playerid"].Value;


This code in C++ does work.
long playerid;
playerid=pRS->Fields->GetItem("playerid")->GetValue();


Can anyone tell me why the C# code isnt working?
I am able to get all the other info in C# (strings).


The error I get is

"Specified cast is not valid"
0
bail3yz
Asked:
bail3yz
1 Solution
 
Pratima PharandeCommented:
try this
  playerid = Convert.ToInt64(pRS.Fields["playerid"].Value);
0
 
bail3yzAuthor Commented:
Perfect! Works great...

Thank you !
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now