.NETGURU
Extended Properties Not Showing Up
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

localhost
I have created a table in MSSQL2K and added an Extended Property to
it.
I want the Extended Property to show up in the result DataSet. What
should I change to make this happen?

TSQL:

Create Table dbo.ZTestTable (
    "ZTestTable_Id" int not null, "Col-1" varchar(184) null,
"Col-2" varchar(238) null
    )
Go

Exec sp_addextendedproperty
'TableType', 'A test table.', 'user', dbo, 'table', [ZTestTable]
Go

Exec sp_addextendedproperty
'ColumnComment', 'ZTestTable primary key identifier.', 'user', dbo,
'table', [ZTestTable], 'column', [ZTestTable_Id]
Go

grant select on ZTestTable to public

Go

C#:

using System;
using System.Data;
using System.Data.OleDb;

class ExtenTest
{
[STAThread]
static void Main(string[] args)
{
    DataSet outSet = new DataSet( "OutSet" );
    string connString = "DATABASE=.........."

//    string selectIt = "Select * From ::fn_listextendedproperty " +
        "('TableType', 'user', 'dbo', 'table','ZTestTable',
null, null)";
    string selectIt = "select * from ZTestTable";
    
    OleDbConnection dbCn = new OleDbConnection( connString );
    dbCn.Open();
    
    OleDbDataAdapter dbAda = new OleDbDataAdapter( selectIt , dbCn
);
    dbAda.Fill( outSet );
    outSet.WriteXml( @"c:\extentest.xml" ,
XmlWriteMode.WriteSchema );

}
}

Thanks.

Reply to this message...
 
    
Kevin Yu [MSFT] (VIP)
Hi localhost,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get extended properties of
a table and fill them to a DataSet. If there is any misunderstanding,
please feel free to let me know.

I have tried your code on my computer, However, I didn't see any exceptions
during running. The properties have been filled and written to the output
xml file. Could you let me know where the problem is?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Reply to this message...
 
    
localhost
I looked at the serialized DataSet and do not see the extended
properties in the schema.

This is the output I get when I view extentest.xml:

<?xml version="1.0" standalone="yes" ?>
<OutSet>
<xs:schema id="OutSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="OutSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="ZTestTable_Id" type="xs:int" minOccurs="0" />
<xs:element name="Col-1" type="xs:string" minOccurs="0" />
<xs:element name="Col-2" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
</OutSet>

I see the table name and column names.
I do not see anything that says "ColumnComment" or "ZTestTable primary
key identifier.".
I want to pull back a result set from SQL Server and any Extended
properties for the
table and columns. I know they are in the DB. How do I get them into
my DataSet?

Thanks.

-----------------------

On Tue, 14 Sep 2004 07:11:29 GMT, Click here to reveal e-mail address (Kevin
Yu [MSFT]) wrote:

[Original message clipped]

Reply to this message...
 
    
Kevin Yu [MSFT] (VIP)
Hi localhost,

I have been following your steps, however, I didn't reproduce it.
XmlWriteMode.WriteSchema will write schema together with data into xml.
Please try to put a DataGrid on the form to display the DataSet. And use
Select * From ::fn_listextendedproperty ('TableType', 'user', 'dbo',
'table','ZTestTable',null, null) in Query Analyzer to check if the extend
properties have been added to the table. Please also make sure that you
have connected to the correct database.

The following is the xml file I have get with WriteXml.

<?xml version="1.0" standalone="yes"?>
<OutSet>
<xs:schema id="OutSet" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="OutSet" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="objtype" type="xs:string" minOccurs="0" />
<xs:element name="objname" type="xs:string" minOccurs="0" />
<xs:element name="name" type="xs:string" minOccurs="0" />
<xs:element name="value" msdata:DataType="System.Object,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<Table>
<objtype>TABLE</objtype>
<objname>ZTestTable</objname>
<name>TableType</name>
<value>A test table.</value>
</Table>
</OutSet>

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Reply to this message...
 
    
localhost
I used Query Analyzer and see that the Extended Properties show up for
both the table and the column ZTestTable_Id.

I do not understand how code that I run on my machine creates
completely different results on your machine. I am running .NET
Framework 1.1-SP1 on WinXP-SP1.

Please post the code that you ran, and please explain why the
ColumnComment Extended Attribute is not showing in your XMLized
DataSet.

Thanks.

On Wed, 15 Sep 2004 08:45:54 GMT, Click here to reveal e-mail address (Kevin
Yu [MSFT]) wrote:

[Original message clipped]

Reply to this message...
 
 
System.Data.DataSet
System.Data.OleDb.OleDbConnection
System.Data.OleDb.OleDbDataAdapter
System.Data.XmlWriteMode
System.Object
System.Web.UI.WebControls.DataGrid
System.Windows.Forms.DataGrid




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification