473,387 Members | 1,742 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,387 software developers and data experts.

Getting a .NET type given a database-specific type name

Hello:

Say I were to query the schema tables from a database management
system. Say I got a DataType field that held the string 'VARCHAR2'.
Now, I know that VARCHAR2 associates to System.String. However,
different DBMSs have different types and worse, even some with the
same type turn out to be different .NET types.

I would like DMBS-independent way of getting a .NET type from a
DataType string. Now, I have existing code that gets the .NET type by
using a DataTable. Somehow DataTables have the .NET types. How is this
done? Do the providers implement the conversion themselves?

Any insight or solutions would be greatly appreciated!

Thanks,
Travis
Jan 17 '08 #1
4 1655
Travis,

Although some types might have been registered in the .NET framework
(Perhaps MSSQL types, not sure!) I don't think all providerd will write
conversion packs. The .NET framework will probably do multiple casts and
returns the most likely result type to your datatable.

Edwin

je**********@gmail.com wrote:
Hello:

Say I were to query the schema tables from a database management
system. Say I got a DataType field that held the string 'VARCHAR2'.
Now, I know that VARCHAR2 associates to System.String. However,
different DBMSs have different types and worse, even some with the
same type turn out to be different .NET types.

I would like DMBS-independent way of getting a .NET type from a
DataType string. Now, I have existing code that gets the .NET type by
using a DataTable. Somehow DataTables have the .NET types. How is this
done? Do the providers implement the conversion themselves?

Any insight or solutions would be greatly appreciated!

Thanks,
Travis
Jan 17 '08 #2
On Jan 17, 2:42*pm, Edwin van Holland <edwinvanholl...@hotmail.com>
wrote:
Travis,

Although some types might have been registered in the .NET framework
(Perhaps MSSQL types, not sure!) I don't think all providerd will write
conversion packs. The .NET framework will probably do multiple casts and
returns the most likely result type to your datatable.

Edwin

jehugalea...@gmail.com wrote:
Hello:
Say I were to query the schema tables from a database management
system. Say I got a DataType field that held the string 'VARCHAR2'.
Now, I know that VARCHAR2 associates to System.String. However,
different DBMSs have different types and worse, even some with the
same type turn out to be different .NET types.
I would like DMBS-independent way of getting a .NET type from a
DataType string. Now, I have existing code that gets the .NET type by
using a DataTable. Somehow DataTables have the .NET types. How is this
done? Do the providers implement the conversion themselves?
Any insight or solutions would be greatly appreciated!
Thanks,
Travis- Hide quoted text -

- Show quoted text -
My biggest problem is that I am not given a column in a table, so that
I could query it. For instance, I am some times given a stored
procedure definition and want to know what the parameter types are.

I can query the metadata table, but it will always return a string
that represents that type on the DBMS. I don't want to have a switch
statement with all the types on the database to map to a .NET type.
Even more, I think calling FillSchema or something similar is overkill
for something that may be called many, many times.

My overall goal to provide the developers here code that would
generate the C# code that would execute a stored procedure. I have
written code that will access the meta data tables and figure out
information about the stored procedures. Right now, my library
supports MySQL, Oracle, MSSQL, PostgreSQL and Access.

With a large number of supported databases and the potential for more,
manually entering in type conversion is buggy and tedious.

I was hoping there was a tool available or a trick to getting the
information.

Thanks for your reply.
Jan 17 '08 #3
Hi,

As you mentioned the mapping change depending of the RDBMS you use. So there
is no way of doing it.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
<je**********@gmail.comwrote in message
news:18**********************************@m34g2000 hsb.googlegroups.com...
Hello:

Say I were to query the schema tables from a database management
system. Say I got a DataType field that held the string 'VARCHAR2'.
Now, I know that VARCHAR2 associates to System.String. However,
different DBMSs have different types and worse, even some with the
same type turn out to be different .NET types.

I would like DMBS-independent way of getting a .NET type from a
DataType string. Now, I have existing code that gets the .NET type by
using a DataTable. Somehow DataTables have the .NET types. How is this
done? Do the providers implement the conversion themselves?

Any insight or solutions would be greatly appreciated!

Thanks,
Travis

Jan 18 '08 #4
On Jan 18, 7:38 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,

As you mentioned the mapping change depending of the RDBMS you use. So there
is no way of doing it.

--
Ignacio Machinhttp://www.laceupsolutions.com
Mobile & warehouse Solutions.<jehugalea...@gmail.comwrote in message

news:18**********************************@m34g2000 hsb.googlegroups.com...
Hello:
Say I were to query the schema tables from adatabasemanagement
system. Say I got a DataType field that held the string 'VARCHAR2'.
Now, I know that VARCHAR2 associates to System.String. However,
different DBMSs have differenttypesand worse, even some with the
same type turn out to be different .NETtypes.
I would like DMBS-independent way of getting a .NETtype from a
DataType string. Now, I have existing code that gets the .NETtype by
using a DataTable. Somehow DataTables have the .NETtypes. How is this
done? Do the providers implement the conversion themselves?
Any insight or solutions would be greatly appreciated!
Thanks,
Travis
Somewhere at some point, someone wrote code to get the .NET type from
the database. There are two possibilities: each RDBMS is responsible
for specifying the mapping; Microsoft somehow wrote a generic class
that could extract the type given an instance of the result. But,
again, I don't have a result.
Jan 19 '08 #5

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

Similar topics

3
by: James | last post by:
Please help - getting very desperate! Sun, 12 October 2003 05:39 I have PHPDEV 4.2.3 from Firepages.com.au as the upgrade to 4.3.0 did not work. I also had an abortive download from PHP.NET as...
2
by: Robin H. Johnson | last post by:
Hi, I'm working on a project making large use of OpenSSL to individually encrypt items inside a database, but I've hit a stumbling block. There appears to be absolutely no native PHP way (eg...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
4
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a...
1
by: Alex | last post by:
Hi all, I'm writing a website with Cold Fusion and when a user submits a request and it's stored in the MS SQL database, I want the unique ID (Identity field in table) to be given to the user on...
5
by: Penny | last post by:
Hi again, Thanks to those who helped before but I'm afraid I waisted your time and effort(especially Bob's) by not detailing the way I was trying to dynamically create the select statement. I...
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
37
by: MLH | last post by:
For example: Nz(,0) returns "300" if the value in field is 300 (currency data type) and "0" if the value is zero or null. I get strings in the query output - they are all left aligned and I...
1
by: jodyblau | last post by:
I applogize for posting this a second time (I posted in the access-multiuser group as well), but this group seems to respond more rapidly, and I have been trying to figure this out for what seems...
5
by: ph3ng | last post by:
Hi I was executing sp_help on a server (ran against master database) and i get the following message: Associated statement is not prepared(HY007) Anyone got any idea what is wrong?
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
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,...
0
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...
0
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,...

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.