473,692 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

type conversion issue.

its on .net 2.0

I am calling a stored procedure which returns value SCOPE_INDENTITY () ,
when i try to convert the result from object to int, it throws a type
conversion error...

after some hit and trials i figured out that the returned type is
actually decimal ..,
hence

int i = (int) DataStore.Execu teScalar(.....) , throws an error

while

decimal d = (decimal) DataStore.Execu teScalar(.....) , works fine ....
is this consistent, is there a ADO.Net conversion map somewhere for SQL
Server ?
regards
-ashish
Dec 14 '05 #1
3 1591
Ashish,

I don't know of where there is a map, but what is the type of your
identity field in SQL?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ashish" <as*****@thisis junk.com> wrote in message
news:OE******** *****@TK2MSFTNG P15.phx.gbl...
its on .net 2.0

I am calling a stored procedure which returns value SCOPE_INDENTITY () ,
when i try to convert the result from object to int, it throws a type
conversion error...

after some hit and trials i figured out that the returned type is actually
decimal ..,
hence

int i = (int) DataStore.Execu teScalar(.....) , throws an error

while

decimal d = (decimal) DataStore.Execu teScalar(.....) , works fine ....
is this consistent, is there a ADO.Net conversion map somewhere for SQL
Server ?
regards
-ashish

Dec 14 '05 #2
the identity field is of type int, another point is that iam using Data
Application Block to access the and they are on 1.1, and my application
is on 2.0, can that cause a problem ?

regards

Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

I don't know of where there is a map, but what is the type of your
identity field in SQL?

Dec 14 '05 #3
Another point is that when i return

SELECT SCOPE_INDENTITY ()

the type returned is System.Decimal

and when i return

SELECT uid FROM Addresses
Then the return value is System.Int32... .

looks like sql_variant is being converted to decimal somehow ...

can someone confirm this ?
regards



Nicholas Paldino [.NET/C# MVP] wrote:
Ashish,

I don't know of where there is a map, but what is the type of your
identity field in SQL?

Dec 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
23163
by: Sean Ross | last post by:
Hi. Recently I made a small script to do some file transferring (among other things). I wanted to monitor the progress of the file transfer, so I needed to know the size of the files I was transferring. Finding out how to get this information took some time (reading the manuals - googling did not prove worthwhile). Anyway, I did eventually figure out how to do it (there are a few ways, including os.path.getsize(filename)). My...
21
2508
by: Nitin Bhardwaj | last post by:
Hi all, It is said that C++ is a strongly typed language and thus a type-safe language (unlike C). So how does one explain the following behaviour : int main(void) { char *p = NULL; p = "A String Literal";//the compiler isuues no error/warning here // but ideally it should...as p is a non-const
19
1692
by: Randy Yates | last post by:
Consider the following code: #include "dsptypes.h" /* definitions */ #define VECTOR_LENGTH 64 /* local variables */
7
4218
by: Ben R. | last post by:
How does automatic type casting happen in vb.net? I notice that databinder.eval "uses reflectoin" to find out the type it's dealing with. Does vb.net do the same thing behind the scenes when an invisible cast is made? Is there any reason why one would use databinder.eval while in VB.NET? I can see why one might use it in C# so as to avoid specifying the type for the cast but since this is not necessary in VB.NET, I'm not sure I follow. ...
4
2109
by: ranjeet.gupta | last post by:
Dear All Please check the below code: UINT8 MsgLength = 0; MsgLength = strlen((char *)msg); if ( MsgLength == 0 || MsgLength 64) {
1
1924
by: jschon | last post by:
How do I compile with g++ version 4.0 so that a int will not be implcitly converted to a string. for example...i would like the following code to result in an error int x = 4; string cat; cat = x;
6
2351
by: NM | last post by:
I am given an int and have to tell whether the bit representation of that int is a palindrome or not. Here is what I have come up with bool isIntPalindrome(int num) { unsigned int temp = num; int reversed = 0; while (num != 0) {
8
5321
by: ma740988 | last post by:
Data stored on a storage device is byte swapped. The data is big endian and my PC is little. At issue: There's a composite type ( a header ) at the front of the files that I'm trying to read in. I'm trying to _simulate_ the endian conversion in code below but I'm just wondering if there's an ideal way to do this besides what's shown? Padding produces some interesting results. Notice how the parameter d is different in the print outs...
0
1039
by: nichols.alan | last post by:
I am attempting to build the SVN release of python on Visual Studio 8. I get the warning messages such as the following: ...\..\Modules\cPickle.c(527) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data ...\..\Modules\binascii.c(285) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data ...\..\PC\_winreg.c(736) : warning C4267: '=' : conversion from
0
8610
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8545
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8810
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4562
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2978
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1961
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.