How to get bigint from database in C#?

Posted on 2009-12-21
Last Modified: 2013-12-14
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;

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"
Question by:bail3yz
    LVL 39

    Accepted Solution

    try this
      playerid = Convert.ToInt64(pRS.Fields["playerid"].Value);

    Author Comment

    Perfect! Works great...

    Thank you !

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Title # Comments Views Activity
    C# ConsolApp opens new window 16 42 mvc 2 30
    Handling arrays 14 27
    Error E2158 compiling with Delphi XE10 Seattle 2 19
    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now