473,549 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert a Double type to an SQLMoney type

I am trying to set Public overridable CreditlimitS() as
System.Data.Sql Types.SqlMoney to Creditlimit as Double
like CreditLimitS=cr editlimit
and get this error "Value of type double cannot be converted to
System.Data.Sql Types.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA
Nov 21 '05 #1
3 7702

Hello Peter,

I read my sql money types in a VB.Net Decimal datatype
regards

M. Posseth
"PeterK" <p.*****@verizo n.net> wrote in message
news:Ot******** ******@TK2MSFTN GP09.phx.gbl...
I am trying to set Public overridable CreditlimitS() as
System.Data.Sql Types.SqlMoney to Creditlimit as Double
like CreditLimitS=cr editlimit
and get this error "Value of type double cannot be converted to
System.Data.Sql Types.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA

Nov 21 '05 #2
Sorry, M, I do not see the solution yet.
This case is about assigning a double variable (i.e. creditlimit) to an
SQLMoney type (creditlimitS), i.e. I cannot choose my destination data type
because that data base (class) exists, and I cannot choose the source data
type because it exists. So I have to somehow convert.
PeterK

"m.posseth" <mi*****@nohaus ystems.nl> wrote in message
news:eu******** ******@TK2MSFTN GP12.phx.gbl...

Hello Peter,

I read my sql money types in a VB.Net Decimal datatype
regards

M. Posseth
"PeterK" <p.*****@verizo n.net> wrote in message
news:Ot******** ******@TK2MSFTN GP09.phx.gbl...
I am trying to set Public overridable CreditlimitS() as
System.Data.Sql Types.SqlMoney to Creditlimit as Double
like CreditLimitS=cr editlimit
and get this error "Value of type double cannot be converted to
System.Data.Sql Types.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA


Nov 21 '05 #3
PeterK,
In addition to the other comments:

You can use the Conversion Operators the SqlMoney defines to convert to/from
Decimal & SqlMoney along with the Conversion operators that VB defines to
convert to/from Decimal & Double.

http://msdn.microsoft.com/library/de...rsionTopic.asp

http://msdn.microsoft.com/library/de...rsionTopic.asp

The "problem" is that VB 2002 & 2003 do not normally see the above
conversion operators. You need to use "Tools - Options - Text Editor -
Basic - General - Hide Advanced members" to show or hide the above advance
members. Once the above members are shown, you can use Intellisense on them.

Something like:

Dim money As SqlTypes.SqlMon ey
Dim dollar As Double

money = SqlTypes.SqlMon ey.op_Implicit( CDec(dollar))
dollar = SqlTypes.SqlMon ey.op_Explicit( money)

VB 2005 (aka Whidbey, due out Nov 7th 2005) will have full support for
overloading conversion operators, so the above two methods will work with
CType!

Something like (untested):

' VB 2005 syntax
Dim money As SqlTypes.SqlMon ey
Dim dollar As Double

money = dollar
dollar = CDec(money)

' alternatively you can use CType directly
money = CType(dollar, SqlTypes.SqlMon ey)
dollar = CType(money, Double)

NOTE: I have not tested the above, you may need to convert to/from Decimal
first, then explicitly convert to/from Decimal & Double. I don't remember if
it allows two implicit conversions in a row (SqlMoney to Decimal, then
Decimal to Double). In other words you may need:

money = CType(CType(dol lar, Decimal), SqlTypes.SqlMon ey)
- or -
money = CType(CDec(doll ar), SqlTypes.SqlMon ey)

Remember that CDec(?) is short hand for CType(?, Decimal).

Hope this helps
Jay

"PeterK" <p.*****@verizo n.net> wrote in message
news:Ot******** ******@TK2MSFTN GP09.phx.gbl...
|I am trying to set Public overridable CreditlimitS() as
| System.Data.Sql Types.SqlMoney to Creditlimit as Double
| like CreditLimitS=cr editlimit
| and get this error "Value of type double cannot be converted to
| System.Data.Sql Types.SqlMoney "
| How do I get creditlimit into creditlimitS?
| There seems to be no conversion function.
| TIA
|
|
Nov 21 '05 #4

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

Similar topics

0
995
by: Chris B. | last post by:
SqlMoney is not serializable and it is sealed to prevent creating a serializable child class. That seems like a waste of a perfectly useful datatype that could have been a member of internal business data objects used with remoting to be inserted in MS SQL Server.
2
4953
by: Pascal | last post by:
Why does this not work, and how should i do this convert in stead: string x = double.MinValue.ToString(); double y = Convert.ToDouble(x); i get this exception: An unhandled exception of type 'System.OverflowException' occurred in mscorlib.dll Additional information: Value was either too large or too small for a Double. Pascal
2
29477
by: jiangyh | last post by:
hi there : I have a question about how to convert Type to DbType? thanks a lot. jiangyh
17
4350
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge problem writing VB Double values to the file so as the Pascal program can read them as Pascal Real values. I've managed to find the algorithm to...
3
2244
by: Eric BOUXIROT | last post by:
hi, i must convert all of these eVC++ prototypes to use with VB.NET.... DLLEXPORT long F_BDO_MessageBoxOK(char *IN_title, char *IN_msg ); DLLEXPORT long F_BDO_MessageBoxOUINON(char *IN_title, char *IN_msg ); DLLEXPORT long F_BDO_CalculAXplusB(short int *IN_Tab_entree ,int IN_taille , double *OUT_Tab_sortie_freq , double *OUT_Tab_sortie,...
28
4793
by: MLH | last post by:
The largest integer A97 can deal with is 2,147,483,647, as I understand it from HELP. I would be content to represent larger integers as strings. For example, "2147483648" would suit me fine. I would be interested in converting larger HEX numbers to decimal integer equivalents. For example, a 16-digit HEX number is quite a large decimal value...
4
2867
by: a.frank81 | last post by:
I have problems with this Code: Public Sub SetPropertyValue(ByVal strPropertyPath As String, ByVal obj As Object, ByVal Value As Object) ..... Dim t_PropertyInfos() As System.Reflection.PropertyInfo = (t_obj.GetType).GetProperties For ii = 0 To t_PropertyInfos.Length - 1 If t_PropertyInfos(ii).Name = t_strProperty Then...
3
63049
by: rishabhshrivastava | last post by:
Hello All, How can I convert a value to Double in JavaScript??? In vbscript i believe its done as cDbl(Value) I tried lots of way but getting a value of "NaN". Any suggestions/ideas will be truely appreciated.
3
8724
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; this produced an error
0
7546
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...
0
7471
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...
0
7740
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7985
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7830
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...
0
6071
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...
1
5387
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...
0
3496
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1962
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

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.