Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 SQL Server 2000 'bigint' == C++ 'long' - correct?

Author  Topic 

sbt1
Yak Posting Veteran

89 Posts

Posted - 2003-05-28 : 13:14:38
I'm trying to read and write a field of type bigint using a C++ long. Isn't that the correct C++ data type to match a bigint?

If I try using an int, I get an invalid type error. But using a long, the database gives me an error that I'm violating a table constraint (but I don't have any set).

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-05-28 : 13:24:39
Looks like you are doing an INSERT...could you post the offending SQL statement and the error you get?

Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2003-05-28 : 13:28:41
A long in C++ must be at least 32 bits. However, you're only likely to find it using 64 bits when programming on a 64 bit architecture. If you're using Visual C++, perhaps you want __int64. I think the GNU compiler has something called "long long", which is borrowed from ISO C99.


Edited by - Arnold Fribble on 05/28/2003 13:30:58
Go to Top of Page

sbt1
Yak Posting Veteran

89 Posts

Posted - 2003-05-28 : 15:46:38
Error I get is:

"A specified value violated the integrity constraints for a column or table. Failed to insert record".

Now, I should point out that I'm using an OLE DB library by Sypram Technology to access the database from my C++ code.

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-05-28 : 21:55:24
That sounds like a limitation with the OLE DB driver, you might want to check if you have the most recent version, and if you do, contact the vendor and ask/inform them of the problem and if their product can support it. Otherwise you may need to look at using another product.

Also, make sure you're not using an unsigned C++ numeric datatype. SQL Server numeric types are signed, with the exception of tinyint. The error you got suggests your datatype is unsigned and there's a value that exceeds the capacity of the SQL Server type.

Go to Top of Page
   

- Advertisement -