Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to determine the type of a SQL column?
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00712325
Message ID:
00712346
Vues:
8
Jayesh,

I tried
DataColumn DC = (DataColumn)Attributes.Rows[i]["DataType"];
But that generated a runtime with a 'Specified cast is invalid.' I'm not sure how to implement your suggestion.
Thanx,
Doug
>What I got from your question is that you are looking to find out easy way to get datatype of a datacolumn.
>
>>Jayesh,
>>
>>I'm not sure what you are telling me in the context of my question.
>>
>>I know I can use DataColumn to build a table. Could you give me an example of DataColumn deconstructing an existing table and exposing its contents?
>>
>>Thanks,
>>Doug
>>>Did you try DataColumn.DataType property?
>>>
>>>>All,
>>>>
>>>>I've been using GetSchemaTable() to retrieve the attributes for columns in a SQL table.
>>>>
>>>>I was wondering how to determine the specific datatype of the column.
>>>>
>>>>DataTable Attributes = DR.GetSchemaTable();
>>>>
>>>>for(int i;i < Attributes.Rows.Count; i++)
>>>>{
>>>>   Att[i,0] = Attributes.Rows[i]["ColumnName"];
>>>>   Att[i,1] = Attributes.Rows[i]["AllowDBNull"];
>>>>   Att[i,2] = Attributes.Rows[i]["DataType"];
>>>>}
>>>>
>>>>
>>>>If I examine Attributes.Rows[i]["DataType"] in the watch window I see {System.RuntimeType}. Below it I see the plus sign in the square with
>>>>System.Type {"System.String"}
>>>>
>>>>How can I readily determine that Attributes.Rows[i]["DataType"] = "String" ?
>>>>
>>>>I tried Reflection with Type t = Attributes.Rows[i]["DataType"].GetType(); But that did not further the crusade either.
>>>>
>>>>This is probably simple, but I do not see the tree in the forest.
>>>>TIA,
>>>>Doug
Douglas Osborne
Don't spend your life just wishing - http://www.AllGiftRegistry.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform