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
 Development Tools
 ASP.NET
 Converting sql server data types to c# types

Author  Topic 

Guran
Starting Member

17 Posts

Posted - 2004-11-02 : 16:58:35
I need to convert the data types in sql server to the normal data types in c#. Most of them are easy to convert (like int, smallint...). Some however are harder. If anyone can help me with the following data types I would be very happy:
money
smallmoney
real
datetime
smalldatetime
binary
varbinary
image
timestamp
uniqueidentifier

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-11-02 : 17:36:51
HAve a look at the following article, about 2/3 the way down is a data conversion chart:

http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=454
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2004-11-02 : 17:51:34
that is a good link, thanks ehorn.


-ec
Go to Top of Page

Guran
Starting Member

17 Posts

Posted - 2004-11-04 : 07:03:06
Thanks! Just what I needed.
Just one question. My application reads a string containing the name of the sql server type and returns the C# type as an object of the class Type. How would you return for example varbinary? As an ArrayList?
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-11-04 : 16:36:15
Hi!

I am not sure I agree totally with the author of that article,
but I am very interested if any have any comments on the following:

I used this to map ths sql server datatypes to .NET types:
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatasqldbtypeclasstopic.asp[/url]

The main difference to the author is the money & char types.

rockmoose
Go to Top of Page
   

- Advertisement -