直接查询SQL以获取表单字段数据吗? [英] Query SQL directly for form field data?

查看:307
本文介绍了直接查询SQL以获取表单字段数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在创建的表单中有一个表单字段,该字段不显示任何文本...但是应该显示.在我们的例子中,表单字段称为:操作更新"

We have a form field within a form that we've created that doesn't show any text...but it should. In our case, the form field is called: "Action Updates"

有没有一种方法可以使用简单的SQL语句直接查询数据库,以查看归档的DOES是否确实包含数据...或者SharePoint只是出于某种原因拒绝显示它?

Is there a way to query the database directly with a simple SQL statement to see if the filed DOES actually contain data...or is SharePoint simply refusing (for some reason) to display it?

谢谢!

推荐答案

埃德,

您在哪里托管表单?您将表单作为可视Webpart托管在sharepoint中吗?还是在共享点之外构建应用程序?

where are you hosting the form? you host the form as visual webpart in sharepoint ? or you build an application outside the sharepoint ? 

您还说过,您有一个名为操作更新"的字段, ?是SharePoint列表中的一个字段吗?还是自定义数据库中的列?

Also , you said you have field called "Action Updates " ? is it a field in SharePoint List ? or it is column in custom database ?

如果数据存储在共享点列表中,则必须使用SharePoint服务器模型,客户端对象模型或Web服务来获取要在表单上显示的字段的值,不建议/不建议连接直接到 sharepoint数据库或在任何SharePoint数据库上执行直接sql查询.

if your data stored in sharepoint list, then you have to use etiher SharePoint server Model , Client Side Object model , or webservice for getting the value of the field to display on your form , it isn't recommended/supported to connect directly to the sharepoint database or executing direct sql queries on any SharePoint databases.

以下是如何从列表中的特定字段读取值的示例

Here's a sample how to read values from specific field in a list

using (SPSite site = new SPSite("SiteURL"))
  {
    using (SPWeb web = site.OpenWeb())
     {
       if (web != null)
         {
           SPQuery query = new SPQuery();
           query.ViewAttributes = "Scope='Recursive'";
           query.RowLimit = 2000;
           CamlQuery caml = new CamlQuery();
       caml = "<OrderBy Override='TRUE'><FieldRefName='ID'/></OrderBy>"
           query.Query = caml ;
           SPList list = web.Lists["MyListName"];
               SPListItemCollection listitem = list.GetItems(query);

                 foreach(SPListItem item in listitem)
                     {
                        //Access your column data

            string MyColumn1 = item["Action Updates"];
            //For lookup columns

                     }

                    }

                }

            }



这篇关于直接查询SQL以获取表单字段数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆