|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Obtaining column properties in .NETHi all,
I want to obtain column properties using C# and the System.Data namespace. Using DbDataReader.GetSchemaTable() or DataAdapter.Columns I only retrieve properties like DataColumn.MaxLength or DataColumn.AllowDbNull in a correct fashion. But if I want properties like DefaultValue or certain column validation rules, I fail. Does anyone know how to obtain these values? If so, please post some sample code or links. Thank you very much in advance. Regards, Hannes What database you target?
Show quote "schnei***@rehm.de" wrote: > Hi all, > > I want to obtain column properties using C# and the System.Data > namespace. Using DbDataReader.GetSchemaTable() or DataAdapter.Columns > I only retrieve properties like DataColumn.MaxLength or > DataColumn.AllowDbNull in a correct fashion. But if I want properties > like DefaultValue or certain column validation rules, I fail. Does > anyone know how to obtain these values? If so, please post some sample > code or links. > Thank you very much in advance. > > Regards, > Hannes > > schnei***@rehm.de wrote:
> Hi all, Please don't crosspost questions to both .data.ado (a classic ado group) and > > I want to obtain column properties using C# and the System.Data > namespace. Using DbDataReader.GetSchemaTable() or DataAdapter.Columns > I only retrieve properties like DataColumn.MaxLength or > DataColumn.AllowDbNull in a correct fashion. But if I want properties > like DefaultValue or certain column validation rules, I fail. Does > anyone know how to obtain these values? If so, please post some sample > code or links. ..dotnet.framework.adonet. Most questions will be relevant in only one of those groups. In this case, only the adonet group is relevant. That said, most databases have system tables or views from which you can get this information. Please specify the database you are using. Followup-To set to microsoft.public.dotnet.framework.adonet -- Microsoft MVP - ASP/ASP.NET Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
Show quote
On 19 Okt., 13:27, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom> Hi,wrote: > schnei***@rehm.de wrote: > > Hi all, > > > I want to obtain column properties using C# and the System.Data > > namespace. Using DbDataReader.GetSchemaTable() or DataAdapter.Columns > > I only retrieve properties like DataColumn.MaxLength or > > DataColumn.AllowDbNull in a correct fashion. But if I want properties > > like DefaultValue or certain column validation rules, I fail. Does > > anyone know how to obtain these values? If so, please post some sample > > code or links. > > Please don't crosspost questions to both .data.ado (a classic ado group) and > .dotnet.framework.adonet. Most questions will be relevant in only one of > those groups. In this case, only the adonet group is relevant. > > That said, most databases have system tables or views from which you can get > this information. Please specify the database you are using. > > Followup-To set to microsoft.public.dotnet.framework.adonet > -- > Microsoft MVP - ASP/ASP.NET > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" first, sorry for cross-posting. I'll try to remind this in the future. My goal is to use an Access database as schema template for customizing another database which can be Access again or Microsoft SQL Server, Oracle, MySQL, ... For example if a new column is introduced with the template database, this column should be applied to all other databases including DefaultValue and other properties. I'm aware that not all Access database features will be supported in the other database applications, but e.g. Default Values will. I need to obtain this column schema and apply it to columns in the "child databases". Thanks again in advance for your help. Regards, Hannes On Fri, 19 Oct 2007 03:01:52 -0700, schnei***@rehm.de wrote:
¤ Hi all, ¤ ¤ I want to obtain column properties using C# and the System.Data ¤ namespace. Using DbDataReader.GetSchemaTable() or DataAdapter.Columns ¤ I only retrieve properties like DataColumn.MaxLength or ¤ DataColumn.AllowDbNull in a correct fashion. But if I want properties ¤ like DefaultValue or certain column validation rules, I fail. Does ¤ anyone know how to obtain these values? If so, please post some sample ¤ code or links. ¤ Thank you very much in advance. The generic method, which relies on functionality supported by the OLEDB provider, is GetOleDbSchemaTable. HOW TO: Retrieve Meta Data from Excel by Using GetOleDbSchemaTable in Visual C# .NET http://support.microsoft.com/kb/318452/zh-cn Keep in mind that database specific implementations will likely require alternative methods. Paul ~~~~ Microsoft MVP (Visual Basic) |
|||||||||||||||||||||||