473,378 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

appropriate C# types for SqlDbType.Money and SqlDbType.DateTime?

hello all,

silly question, but i can't find a thread that answers it. i have
stored procedures that have output parameters of the datatypes Money
and DateTime.

i have the following sample code to extract those parameters into class
properties:

public float P1 = (float) oSqlCmd.Parameters["@Money1"].Value;
publid DateTime P2 = (DateTime) oSqlCmd.Parameters["@Date1"].Value;

however, those are not legal implicit conversions. so my questions are:

1) what's the appropriate datatype to use for members in c# classes for
these datatypes?
2) what's the appropriate way to convert from these datatypes to the c#
datatypes (unless of course implicit conversion is possible)

thanks for any help,

jason

Nov 17 '05 #1
2 7962
Hi,

IIRC there is an article in MSDN about this.

Money can be represented as decimal and DateTime with DateTime :)

In anyway you should use the correct Convert.ToXXXX method
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"jason" <ia****@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
hello all,

silly question, but i can't find a thread that answers it. i have
stored procedures that have output parameters of the datatypes Money
and DateTime.

i have the following sample code to extract those parameters into class
properties:

public float P1 = (float) oSqlCmd.Parameters["@Money1"].Value;
publid DateTime P2 = (DateTime) oSqlCmd.Parameters["@Date1"].Value;

however, those are not legal implicit conversions. so my questions are:

1) what's the appropriate datatype to use for members in c# classes for
these datatypes?
2) what's the appropriate way to convert from these datatypes to the c#
datatypes (unless of course implicit conversion is possible)

thanks for any help,

jason

Nov 17 '05 #2
ahh, convert instead of implicit casting. that must be what i was
missing. thanks!

Nov 17 '05 #3

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

Similar topics

5
by: Kenneth | last post by:
Can anyone explain me why it is neccesary to include SqlDbType to the SqlParameter. In every example I see, it is done, but no one explaines why. I have for example a date I want to save into my...
2
by: valmir cinquini | last post by:
Hi everybody I'm newbee in C# and I'm supporting an application where there's a method like following: public int addNews(DateTime dtNews, string strTitle, string strShortText, string...
3
by: Narshe | last post by:
If I use this simple code SqlParameter param = new SqlParameter( "@param", SqlDbType.DateTime ); param.Value = System.DateTime.Now; param.Value is "11/2/2005" rather than "11/2/2005 10:42:15...
9
by: Jerome | last post by:
Hi, I keep getting the same compiler error: 'Name 'SqlDbType' is not declared' and I don't know why? I've declared the following: <%@ Page Language="VB" ContentType="text/html"...
2
by: adams114 | last post by:
I am having a strange problem with invalid type casts. I am trying to update a MS SQL Database with a stored procedure. When I setup the parameters collection for the command object I get a invalid...
1
by: patrick | last post by:
I have tried using 2 type systems to get this to compile but it still gets the same error: Public MustInherit Class _Applications Private _AppID As System.Decimal Private _AppPosition As...
5
by: Roy | last post by:
The SqlCommand.Parameters.Add(..) function takes an paramter for SqlDBType. Is there a generic way in .NET framework to convert .net types to SqlDBTypes? Or I have to mapping manually with a big...
11
by: mesut demir | last post by:
Hi All, When I create fields (in files) I need assign a data type like char, varchar, money etc. I have some questions about the data types when you create fields in a file. What is the...
4
by: Chris Bordeman | last post by:
I have a DataColumn, want to derive the DbType. I can do column.GetType() but that's a system type, not a db type. How do I convert it to the corresponding type? Thanks much! Chris B.
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.