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


C# Connection.sqlQuery方法代码示例

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


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

示例1: GenerateGrid

    private void GenerateGrid(DataTable dt)
    {
        String grid = "";
        String sql = "";
        conn = new Connection(System.Configuration.ConfigurationManager.ConnectionStrings["ConStrLANDCOMPLocal2"].ToString());

        if ((Session["usersWilay"] is object) && (Session["userID"] is object))
        {
            wilayah = "0" + Session["usersWilay"].ToString();
            user = Session["userID"].ToString();
        }

        try
        {
            sql = "DECLARE @LookupType varchar(10); SET @LookupType='"+lt+"'; "
                + "DECLARE @LookupParams varchar(1000); SET @LookupParams='" + lps + "'; "
                + "DECLARE @LookupSearch varchar(1000); SET @LookupSearch='" + ls + "'; "
                + "DECLARE @LookupWilayah varchar(10); SET @LookupWilayah='" + wilayah + "'; "
                + "EXEC landcomp.[c_lookup] "
                + "@LookupType"
                + ",@LookupParams"
                + ",@LookupSearch"
                + ",@LookupWilayah"
                + "";
            dt = conn.sqlQuery(sql);

            grid = "<rows>" + grid + GenerateHead(dt);
            grid = grid + GenerateContent(dt) + "</rows>";

            Response.ContentType = "application/xhtml+xml";
            //Response.ContentType = "text/plain"; // for debuging
            Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            Response.Write(grid);
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
        Response.End();
    }
开发者ID:VikySihabudin,项目名称:Landai,代码行数:40,代码来源:Lookup.aspx.cs

示例2: ServiceSelect

    private bool ServiceSelect(string sm)
    {
        String sql = "";
        conn = new Connection(System.Configuration.ConfigurationManager.ConnectionStrings["ConStrLANDCOMPLocal2"].ToString());
        DataTable dt = new DataTable();
        switch (sm)
        {
            case "l":
                sql = "SELECT codessHeadss, codessCodess, codessDescs1, codessDescs2, codessStatss "
                     +" from almis.CODESS where codessCodess=0"
                     + "";
                dt = conn.sqlQuery(sql);

                Response.ContentType = "application/xhtml+xml";
                Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                Response.Write("<rows>");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Response.Write("<row id=\"" + RemoveWhiteSpace(dt.Rows[i]["codessHeadss"].ToString()) + "\">");
                    Response.Write("<cell>" + (i + 1).ToString() + "</cell>");
                    Response.Write("<cell>" + RemoveWhiteSpace(dt.Rows[i]["codessHeadss"].ToString()) + "</cell>");
                    Response.Write("<cell>" + RemoveWhiteSpace(dt.Rows[i]["codessDescs1"].ToString()) + "</cell>");
                    Response.Write("<cell>" + RemoveWhiteSpace(dt.Rows[i]["codessDescs2"].ToString()) + "</cell>");
                    Response.Write("<cell>" + RemoveWhiteSpace(dt.Rows[i]["codessStatss"].ToString()) + "</cell>");
                    Response.Write("</row>");
                }
                Response.Write("</rows>");
                dt.Dispose();
                conn.myConnectionClose();
                Response.End();
                return false;

            case "li":
                idcodehead.Value = Request.Params["id"].ToString();
                String idrow = Request.Params["id"].ToString();
                sql = "SELECT codessHeadss,codessCodess,ISNULL(codessDescs1,'') codessDescs1,ISNULL(codessDescs2,'') codessDescs2,codessStatss FROM almis.CODESS  where codessStatss!=0 and codessHeadss=" + idrow
                    + "ORDER BY codessCodess";
                dt = conn.sqlQuery(sql);

                Response.ContentType = "application/xhtml+xml";
                Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                Response.Write("<rows>");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Response.Write("<row id=\"" + dt.Rows[i]["codessCodess"].ToString() + "\">");
                    Response.Write("<cell>" + (i + 1).ToString() + "</cell>");
                    Response.Write("<cell>" + dt.Rows[i]["codessCodess"].ToString() + "</cell>");
                    Response.Write("<cell>" + dt.Rows[i]["codessDescs1"].ToString() + "</cell>");
                    Response.Write("<cell>" + dt.Rows[i]["codessDescs2"].ToString() + "</cell>");
                    Response.Write("<cell>" + dt.Rows[i]["codessStatss"].ToString() + "</cell>");
                    Response.Write("<cell>" + dt.Rows[i]["codessHeadss"].ToString() + "</cell>");
                    Response.Write("</row>");
                }
                Response.Write("</rows>");
                dt.Dispose();
                conn.myConnectionClose();
                Response.End();
                return false;

            case "s":
                String id = Request.Params["id"].ToString();
                sql = "SELECT codessHeadss,codessCodess,codessDescs1,codessDescs2,codessStatss FROM almis.CODESS where codessHeadss=" + Request.Params["codeid"].ToString()
                    + "  and codessCodess= " + id
                    + "";
                dt = conn.sqlQuery(sql);

                Response.ContentType = "text/plain";

                Response.Write(dt.Rows[0]["codessHeadss"].ToString() + "|");
                Response.Write((dt.Rows[0]["codessCodess"].ToString()) + "|");
                Response.Write((dt.Rows[0]["codessDescs1"].ToString()) + "|");
                Response.Write(dt.Rows[0]["codessDescs2"].ToString() + "|");
                Response.Write(dt.Rows[0]["codessStatss"].ToString());

                dt.Dispose();
                conn.myConnectionClose();
                Response.End();
                return false;

            case "i":
                String tipe = Request.Params["tipe"].ToString();
                String codehead = Request.Params["id"].ToString();
                String idcodes = Request.Params["idcodes"].ToString();
                String codessDescs1 = Request.Params["codessDescs1"].ToString();
                String codessDescs2 = Request.Params["codessDescs2"].ToString();
                string user = (string)Session["userID"].ToString();
                String output = "";
                String idCLS = Request.Params["id"].ToString();
                Response.ContentType = "text/plain";
                if (tipe == "1")
                {
                    sql = @"select codessCodess from almis.CODESS where codessHeadss='" + codehead + @"'
                            and codessDescs1='" + codessDescs1 + "' ";

                    DataTable dt0 = new DataTable();
                    dt0 = conn.sqlQuery(sql);
                    output = dt0.Rows.Count.ToString();
                    if (output != "0")
                        Response.Write("Nama Item tidak boleh sama");
                }
//.........这里部分代码省略.........
开发者ID:VikySihabudin,项目名称:almis,代码行数:101,代码来源:CodesModul.aspx.cs


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