Re: Database datatype to c# datatype




"Marc Gravell" <marc.gravell@xxxxxxxxx> skrev i en meddelelse
news:urmVT2IhGHA.4104@xxxxxxxxxxxxxxxxxxxxxxx
For most DAL purposes you know the type (per column) in advance, since you
designed the database; for more generic usage, you can always use
GetFieldType() and GetValue() on any IDataReader.

Would that do?

Not quite (I don't think), because I get metadata about a database column:

name
default value
is nullable
data type

ie, I get an IDataReader which contains some "string columns", which provide
information about a column in a database table.

One of the items of data describing the column is a string value which gives
the data type of the column. For example, this string value could be
"varchar" or "int".

I want to convert this string value to a c# datatype.



Peter


.



Relevant Pages

  • Re: runtime error with Mask edit control
    ... DateOfBirth property is a string. ... If no value is entered into the Property, the database stores a null. ... > its data type (one would assume the same as the property, ...
    (microsoft.public.vb.controls)
  • Re: How to represent variable data types?
    ... double, integer, string, and timestamp. ... don't know the data type we're looking for. ... I'm working on refactoring the database this week, ...
    (comp.databases)
  • Re: Dynamic cast string value to a specific data type for stored procedure
    ... Robbe Morris - 2004-2006 Microsoft MVP C# ... I've mapped the database to .NET class properties and methods to ... - Stored procedure input parameters data type specific (SqlDbType.Int, ... I need a function that would grab the string value and dynamically ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A little Rolodex [revised]
    ... including alpha sort and searching for any embedded string, ... In this application, a database is a directory, ... you may optionally provide any alternate UCASE program, ... NN -> first store NN as key length ...
    (comp.sys.hp48)
  • Re: return multiple rows from sql statement
    ... strings from input values is almost certainly a safe path to SQL ... Also, being a MySQL function, it knows what MySQL needs or uses. ... All characters that are entered in the fields make their way into the database unaltered. ... The insert of what surprisinlgly was NOT a syntax error, but a string called "mysql_insert_id" into an integer field resulted in the value zero being put in. ...
    (comp.lang.php)

Quantcast