我制作了一个 SQL CLR 函数来从 SharePoint 网站检索数据。这是返回给 SQL 的部分:
public static void GetListItemInfo(
object obj,
out SqlString Name,
out SqlString SO,
out SqlString LineNumber,
out SqlString SerialNumber,
out SqlString Certificates,
out SqlString Tags,
out SqlString RevisionNumber)
{
DataRow r = (DataRow)obj;
Name = new SqlString(r["ows_LinkFilename"].ToString());
SO = new SqlString(r["ows_SO"].ToString());
LineNumber = new SqlString(r["ows_Line_x0020_Number"].ToString());
SerialNumber = new SqlString(r["ows_Unit_x0020_Number"].ToString());
Certificates = new SqlString(r["ows_Certificate_x0020_Type"].ToString());
Tags = new SqlString(r["ows_Tags"].ToString());
RevisionNumber = new SqlString(r["ows_Revision_x0020_Number"].ToString());
}
所有这些都是 SharePoint 列表中存在的列名,但是当我从 SQL 运行该函数时,它会显示此错误:
Msg 6260, Level 16, State 1, Line 1
An error occurred while getting new row from user defined Table Valued Function :
System.ArgumentException: Column 'ows_Line_x0020_Number' does not belong to table row.
System.ArgumentException:
at System.Data.DataRow.GetDataColumn(String columnName)
at System.Data.DataRow.get_Item(String columnName)
at SharePointToSQL.GetListItemInfo(Object obj, SqlString& SO, SqlString& LineNumber, SqlString& Tags)
但是,如果我尝试仅获取“SO”和“标签”列,则不会出现此错误,因为其他所有内容都不起作用。
更新: 我发现我能够返回“ows_SO”“ows_Sample”等列,但不能返回“ows_Line_x0020_Number”等列。我可以通过稍微更改列名来做我想做的事。但是谁能告诉我为什么不能使用像“ows_Line_x0020_Number”这样的列名?