Extended Properties SQL Server 2005

Anything that doesn't fall into the defect or enhancement categories

Extended Properties SQL Server 2005

Postby dnordin on Sat Mar 15, 2008 5:33 pm

Hello,

I'm having difficulty accessing Table extended properties in SQL server.

My script is C#.

I'm using the following code snippet I found on a post last year.

Code: Select all
MyMeta.Single single = MyMeta.Databases[0].Tables[0] as MyMeta.Single;
KeyValueCollection extendedProperties = single.DatabaseSpecificMetaData(\"ExtendedProperties\") as KeyValueCollection;


The KeyValueCollection is not null but it is always empty.

The connection string is of the form:

Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBName;Data Source=ServerName

The DB Target is SqlClient

The Driver is Microsoft SQL Server

What am I missing? Is there something special in the connection string I need or has the syntax changed for this? I'm running version 1.3.0.3 of the generator MyMeta 1.3.0.0

Thanks,

Dan
dnordin
Lurker
 
Posts: 5
Joined: Sat Mar 15, 2008 5:07 pm

Postby mike.griffin on Sat Mar 15, 2008 5:54 pm

I think you need to have admin privileges on your database, do you have that?
User avatar
mike.griffin
Site Admin
 
Posts: 3290
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN

Postby dnordin on Sat Mar 15, 2008 5:57 pm

Yes, I'm an admin on the server / db
dnordin
Lurker
 
Posts: 5
Joined: Sat Mar 15, 2008 5:07 pm

Postby mike.griffin on Sun Mar 16, 2008 2:19 am

Hmmm, your connection string looks funny?

Provider=SQLNCLI.1;

We use OLEDB, please use our OLEDB button on the default settings dialog to setup your connection and it should work.
User avatar
mike.griffin
Site Admin
 
Posts: 3290
Joined: Sat Apr 03, 2004 6:10 am
Location: Indianapolis, IN

Postby dnordin on Mon Mar 17, 2008 6:26 pm

My original connection string (built using the MyGeneration OLEDB dialogues) was:

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=DBName;Data Source=ServerName

I thought maybe the problem was in the SQLOLEDB so I changed the provider (again using the dialouges provided) and changed it to the SQL Native provider: SQLNCLI.1

In either case I always get zero rows in the collections.

I've tested with table and column extended properties and with more than one property defined but still no luck.
dnordin
Lurker
 
Posts: 5
Joined: Sat Mar 15, 2008 5:07 pm

Postby dnordin on Mon Mar 17, 2008 6:29 pm

I notice when debugging that a few of the object in the MyMeta model have an XPath property implying to me that they hold their information in XML. Is there a property / method somewhere that will show me the complete XML document that makes up MyMeta's understanding of my database?
dnordin
Lurker
 
Posts: 5
Joined: Sat Mar 15, 2008 5:07 pm

Postby dnordin on Mon Mar 17, 2008 7:17 pm

I found the problem:

looking through the source code on line I noticed that in MyMeta.Sql.DatabaseSpecific you are using the following query to extract the properties:

Code: Select all
private const string QUERY = @\"SELECT [name], [value] FROM ::fn_listextendedproperty (NULL, 'user', {0}, {1}, {2}, {3}, {4})\";


SQL books online informs us that having 'user' in the second position is depricated and should now be 'schema'.

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/59bbb91f-a277-4a35-803e-dcb91e847a49.htm

The database I am using does indeed leverage multiple schema, when I run the query in SQL Management Studio with 'user' changed to 'schema' I get the result set I am expecting.
dnordin
Lurker
 
Posts: 5
Joined: Sat Mar 15, 2008 5:07 pm


Return to General Questions or Comments

Who is online

Users browsing this forum: No registered users and 2 guests

cron