How can I find SharePoint list fields from a database in SharePoint 2010?

In SharePoint 2003 and 2007, there was an AllLists table in which there was a column named tp_Fields containing xml containing all the fields for a specific list.

the xml example stored in the tp_Fields column will be displayed in a SharePoint list with three fields:

<FieldRef Name="ContentTypeId" /> <FieldRef Name="_ModerationComments" ColName="ntext1" /> <FieldRef Name="WebPartTypeName" ColName="nvarchar9" /> 

We have an application that reads from this column using C # code, for example.

 var tpFields = (String) drView["tp_Fields"]; 

In SharePoint 2010, the data type of this column has changed to varbinary and contains only some binary data!

(I know that the ideal / recommended solution was to use SharePoint web services or the SharePoint object model and not rely on base tables, but unfortunately we have an existing application and we will need to work with it in 2010 as well. , we don’t have to redesign everything!)

How can I find out which fields from a SharePoint list in my database in SharePoint 2010? or, if possible, how to convert this varbinary column to its equivalent xml as before?

I hope the question is clear (little hope for its tbh capability).

Thanks,

+4
source share
2 answers

Just to share, I wrote a method below, and now it can extract xml from it, although there is no guarantee that the resulting xml is compatible with SharePoint 2003/2007.

  private static string getXmlFromTpFields(byte[] tpFields) { using (var memoryStream = new MemoryStream(tpFields)) { // ignore the first 14 bytes; I'm not sure why but it works! for (var index = 0; index <= 13; index++) memoryStream.ReadByte(); var deflateStream = new DeflateStream(memoryStream, CompressionMode.Decompress); using (var destination = new MemoryStream()) { deflateStream.CopyTo(destination); var streamReader = new StreamReader(destination); destination.Position = 0; return streamReader.ReadToEnd(); } } } 
+1
source

I have been doing this for a long time and found a utility called SPViews . You specify it in the content database and generate a SQL script to create views for you. It reads the compressed field to get the columns and generates a script. You can get the columns from there.

jd

0
source

Source: https://habr.com/ru/post/1392694/


All Articles