当前位置: 首页>>代码示例>>C#>>正文


C# Query.ExecuteQueryCommand方法代码示例

本文整理汇总了C#中Query.ExecuteQueryCommand方法的典型用法代码示例。如果您正苦于以下问题:C# Query.ExecuteQueryCommand方法的具体用法?C# Query.ExecuteQueryCommand怎么用?C# Query.ExecuteQueryCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Query的用法示例。


在下文中一共展示了Query.ExecuteQueryCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DesignGridFromSQL

        public bool DesignGridFromSQL(string sqlParam, ref string strErr)
        {
            try
            {
                strSQL = sqlParam;

                Query objQuery = new Query();

                DataSet ds = objQuery.ExecuteQueryCommand(strSQL);

                dtReadOnlyGrid = ds.Tables[0].Copy();
                dtReadOnlyGrid.TableName = "Table";
                ds.Dispose();
                //Changing For New Component
                //_BSource = new BindingSource(dtReadOnlyGrid, null);

                intColCount = dtReadOnlyGrid.Columns.Count;
                strColNames = new string[intColCount];

                for (int i = 0; i < intColCount; i++)
                    strColNames[i] = dtReadOnlyGrid.Columns[i].ColumnName;

               ///***Displaying data from a Table to a Grid and aligning the Columns***
                intColCount = dtReadOnlyGrid.Columns.Count;
                strColNames = new string[intColCount];

                for (int i = 0; i < intColCount; i++)
                    strColNames[i] = dtReadOnlyGrid.Columns[i].ColumnName;

                string[] strHeadings = new string[intColCount];

                ////**** Creating the Header text by replacing the Underscore(_)
                ////**** Symbol with the Space ( ).

                clsLanguage objLang = new clsLanguage();

                for (int i = 0; i < intColCount; i++)
                {
                    strHeadings[i] = strColNames[i].Replace("_", " ");

                    if (strLangID != null && strColNames[i].IndexOf("MASK_") < 0)
                    {
                        if (strLangID.Length >= intColCount)
                        {
                            string strTmp = objLang.LanguageString(strLangID[i]);
                            if (strTmp == "*****")
                                strHeadings[i] = "** " + strHeadings[i];
                            else
                                strHeadings[i] = strTmp;
                        }
                        else
                        {
                            if (strLangID.Length > i)
                            {
                                string strTmp = objLang.LanguageString(strLangID[i]);

                                if (strTmp == "*****")
                                    strHeadings[i] = "** " + strHeadings[i];
                                else
                                    strHeadings[i] = strTmp;
                            }
                            else
                            {
                                strHeadings[i] = "** " + strHeadings[i];
                            }
                        }
                    }
                    else
                    {
                        strHeadings[i] = "** " + strHeadings[i];
                    }
                }

                if (objLang != null)
                    objLang.Dispose();

                ////**** Creating a new Table Style to include the TextBoxes in the Datagrid
                //this.DataSource =_BSource;
                this.DataSource = dtReadOnlyGrid;
                if (SetDefault == true)
                {

                    //DataGridViewCellStyle headerstyle = new DataGridViewCellStyle();
                    //headerstyle.BackColor = System.Drawing.Color.Linen;
                    //headerstyle.ForeColor = System.Drawing.Color.Navy;
                    //this.GridColor = System.Drawing.Color.Silver;
                    //this.ColumnHeadersDefaultCellStyle.ApplyStyle(headerstyle);

                }
                else
                {
                    //this.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.LightSteelBlue;
                    //this.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.Color.Navy;
                    //this.GridColor = System.Drawing.Color.Silver;

                }

                ////**** To incorporate the Font the in DataGrid Cell.

                intVisibleColumnCount = 0;
//.........这里部分代码省略.........
开发者ID:routd1,项目名称:ProjectHurricane,代码行数:101,代码来源:clsReadOnlyGrid.cs

示例2: ExecuteProcedure

        /// <summary>
        /// Executes a procedure for populating the treegridview
        /// </summary>
        /// <param name="SQLProcName">Procedure Name/SQL query string</param>
        /// <param name="isSQL">true if the supplied 'SQLProcName' if SQL query;else false</param>
        /// <param name="strErrMsg">Error message to be returned</param>
        /// <returns></returns>
        private bool ExecuteProcedure(string SQLProcName, bool isSQL, ref string strErrMsg)
        {
            try
            {
                Query objQuery = new Query();

                if (!isSQL)
                {
                    string[] arrStrProcParamNames = new string[0];
                    string[] arrStrProcParamValues = new string[0];
                    if (ProcParamNames.Count - arlOutParam.Count > 0)
                    {
                        arrStrProcParamNames = new string[ProcParamNames.Count - arlOutParam.Count];
                        arrStrProcParamValues = new string[ProcParamNames.Count - arlOutParam.Count];
                        for (int i = 0; i < ProcParamNames.Count; i++)
                        {
                            if (ProcParamValues[i] != null)
                            {
                                arrStrProcParamNames[i] = ProcParamNames[i].ToString();
                                arrStrProcParamValues[i] = ProcParamValues[i].ToString();
                            }
                        }
                        objQuery.SetInputParameterNames(SQLProcName, arrStrProcParamNames);
                        objQuery.SetInputParameterValues(arrStrProcParamValues);
                    }

                    arrStrProcParamNames = new string[arlOutParam.Count];
                    arrStrProcParamValues = new string[arlOutParam.Count];
                    int iOutParamIndex = 0;
                    for (int i = 0; i < ProcParamNames.Count; i++)
                    {
                        if (ProcParamValues[i] == null)
                        {
                            arrStrProcParamNames[iOutParamIndex++] = ProcParamNames[i].ToString();
                        }
                    }
                    objQuery.SetOutputParameterNames(SQLProcName, arrStrProcParamNames);

                    dsSource = objQuery.ExecuteQueryProcedure(SQLProcName);
                }
                else
                {
                    dsSource = objQuery.ExecuteQueryCommand(SQLProcName);
                }

                dtSource = dsSource.Tables[0].Copy();
                dsSource.Dispose();

                intColCount = dtSource.Columns.Count;
                strColNames = new string[intColCount];

                for (int i = 0; i < intColCount; i++)
                    strColNames[i] = dtSource.Columns[i].ColumnName;

                if (isSQL == false)
                {
                    strProcOutValue = new string[arlOutParam.Count];
                    for (int i = 0; i < arlOutParam.Count; i++)
                    {
                        strProcOutValue[i] = objQuery.GetOutputParameterValue(arlOutParam[i].ToString());
                    }
                }

                dtSource = dsSource.Tables[0];

                dvSource = dtSource.DefaultView;

                dvSource.AllowNew = false;
                intTotalRowCount = dvSource.Count;					//INDRANIL

                //dtSource.Columns.Add("MASK_LOAD_COL_VALUE");

                //for (int i = 0; i < dtSource.Rows.Count; i++)
                //    dtSource.Rows[i]["MASK_LOAD_COL_VALUE"] = "0";

                intColCount = dtSource.Columns.Count - 1;

                //MyGridTextBoxColumn._RowCount = dtSource.Rows.Count;

                ChangeDataTable();

                return true;
            }
            catch (Exception ex)
            {
                strErrMsg = ex.Message + " - " + ex.Source;
                return false;
            }
        }
开发者ID:routd1,项目名称:ProjectHurricane,代码行数:96,代码来源:TreeGridView.cs

示例3: PopulateGrid

        public bool PopulateGrid(string sqlParam, ref string strErr)
        {
            try
            {
                strSQL = sqlParam;

                ///***Displaying data from a Table to a Grid and aligning the Columns***
                Query objQuery = new Query();

                DataSet ds = objQuery.ExecuteQueryCommand(strSQL);

                dtReadOnlyGrid = ds.Tables[0].Copy();
                ds.Dispose();

                intColCount = dtReadOnlyGrid.Columns.Count;
                strColNames = new string[intColCount];

                for (int i = 0; i < intColCount; i++)
                    strColNames[i] = dtReadOnlyGrid.Columns[i].ColumnName;

                this.DataSource = dtReadOnlyGrid;

                this.AutoSize = true;

                RowCount = dtReadOnlyGrid.Rows.Count;

                return true;
            }
            catch (Exception ex)
            {
                strErr = ex.Message + " - " + ex.Source;
                return false;
            }
        }
开发者ID:routd1,项目名称:ProjectHurricane,代码行数:34,代码来源:clsReadOnlyGrid.cs


注:本文中的Query.ExecuteQueryCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。