需要Object引用/不能从引用调用Request

时间:2014-04-02 10:24:30

标签: c# .net umbraco smartsheet-api

我目前正在尝试创建一个新的Umbraco文档,然后请求查询字符串Rid并运行我的代码(这将找到页面的ID并正确显示)但我不能在它是asp.net用户控件时调用引用请求。我收到错误非静态字段,方法或属性需要对象引用" System.Web.Ui.UserControl.Request.get"

错误来自(请求未被识别)

 Document rDoc = new Document(Convert.ToInt32(Request.QueryString["rid"]));

有什么想法吗?代码如下。如果您有任何改进,您可以想到/为什么这段代码不起作用的原因,非常感谢解释,谢谢。

我的包括......

<%@Import Namespace="System.Net" %>
<%@Import Namespace="Newtonsoft.Json" %>
<%@Import Namespace="System.Web"%>
<%@Import Namespace="System.Web.Script.Serialization"%>
<%@Import Namespace="System.IO" %>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.SqlClient" %>
<%@Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.ComponentModel" %>


<%--Umbraco Includes--%>
<%@ Import Namespace="umbraco.cms.businesslogic" %>
<%@ Import Namespace="umbraco.cms.businesslogic.web" %>
<%@ Import Namespace="umbraco.cms.businesslogic.member" %>


  static void Main(string[] args)
        {

            //Hashtable sqlDatatypeholder = new Hashtable();
            Dictionary<string, string> sqlDatatypeholder = new Dictionary<string, string>();
            DataTable tempTable = new DataTable();
            string SheetToPopulate = "";

            //Sql Connection      
            string _mySqlUrl = "sqlurl;";

            string _mySqlQuery = "query;";

            Document rDoc = new Document(Convert.ToInt32(Request.QueryString["rid"]));

            SqlConnection conn = new SqlConnection(_mySqlUrl);

            using (conn)
            {
                SqlCommand command = new SqlCommand(_mySqlQuery, conn);
                conn.Open();

                SqlDataReader reader = command.ExecuteReader();
                DataTable schemaTable = reader.GetSchemaTable(); //stores datatypes from sql
                tempTable.Load(reader); //stores data rows from sql
                reader.Close();

                //we need at least two date datatype fields for the sheet to be viewed in Gantt Chart view (smartsheet API rule), so everytime the date format is found, set to DATE

                if (tempTable != null && tempTable.Rows.Count > 0)
                {
                    foreach (DataRow row in schemaTable.Rows)
                    {
                        sqlDatatypeholder.Add(row["ColumnName"].ToString(), row["DataTypeName"].ToString());
                    }

                }
                else
                {
                    Console.WriteLine("Connection Open - No rows found.");
                    Console.ReadLine();
                }
            }
            SheetToPopulate = CreateSmartSheetFromDictionary(HashtableToDictionary(sqlDatatypeholder), tempTable);

            // Console.WriteLine(SheetToPopulate);
            PopulateSmartSheetRows(SheetToPopulate, tempTable);
            // Console.WriteLine("Sheet Populated");
            //Console.ReadLine();
        }

0 个答案:

没有答案