English 中文(简体)
如何发现 DataColumn s 基础数据类型为 xml
原标题:How to discover that a DataColumn s underlying datatype is xml

我有 SQL 服务器数据表有 xml 列。 我使用 < code> DataTable ( Finll 方法 < code> SqlDataAdapter 类) 的 < code> 方法运行一个选择查询。 执行后, 列的类型为 < code> string 。

我在想我如何从 Datatable 方法中确定实际的 SQL 服务器数据类型(在此情况下为 xml ) 。

我不能使用 SqlDataReader (它有 GetSchemaTable 方法,可以返回 SQL 服务器数据类型信息) - 我不得不使用 SqlDataAdapter/DataTable (它有 GetSchemaTable 方法,可以返回 SQL 服务器数据类型信息) - 我不得不使用 SqlDataAdapter/DataTable 。 做类似的事情:

DataTableReader reader = new DataTableReader(table);
DataTable schemaTable = reader.GetSchemaTable();

也无济于事,因为它似乎也不包含SQL服务器数据类型信息。

问题回答

SqlDataAdapter 上有一个属性,称为 ReturnProviderSpecificType ,如果您设置这个属性为真,那么, GetSchemaTable () 应该告诉你,该列是 typeof(SqlXml) ,而不是 typeof(string)





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签