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


C# SQLHelper类代码示例

本文整理汇总了C#中SQLHelper的典型用法代码示例。如果您正苦于以下问题:C# SQLHelper类的具体用法?C# SQLHelper怎么用?C# SQLHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CreateDatabase

 /// <summary>
 /// Creates a database out of the structure it is given
 /// </summary>
 /// <param name="Database">Database structure</param>
 /// <param name="ConnectionString">The connection string to the database's location</param>
 public static void CreateDatabase(Database Database,string ConnectionString)
 {
     try
     {
         string Command = BuildCommands(Database);
         string[] Splitter = { "\n" };
         string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
         string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "");
         using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
         {
             try
             {
                 Helper.Open();
                 Helper.ExecuteNonQuery();
             }
             catch { throw; }
             finally { Helper.Close(); }
         }
         for (int x = 1; x < Commands.Length; ++x)
         {
             using (SQLHelper Helper = new SQLHelper(Commands[x], ConnectionString, CommandType.Text))
             {
                 try
                 {
                     Helper.Open();
                     Helper.ExecuteNonQuery();
                 }
                 catch { throw; }
                 finally { Helper.Close(); }
             }
         }
     }
     catch { throw; }
 }
开发者ID:pengyancai,项目名称:cs-util,代码行数:39,代码来源:SQLServer.cs

示例2: getNewsDt

        public DataTable getNewsDt()
        {
            SQLHelper db = new SQLHelper();
            try
            {
                string pagesize = Pager1.PageSize.ToString();
                string curpage = pg.request(Pager1.PagePara);
                string pageCount = "";//总页数
                int rowCount = 0;
                if (pagesize == "") pagesize = "10";
                if (curpage == "") curpage = "1";
                string sql = "SELECT id,name,OrderId,JianCheng FROM " + com.tablePrefix + "province WHERE 1=1 ";

                sql += " ORDER BY OrderId";
                sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
                db.sql = sql;
                DataSet ds = db.Get_DataSet();
                DataTable dt = ds.Tables[2];
                pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
                rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
                Pager1.RecordCount = rowCount;
                //if (rowCount == 0) Pager1.Visible = false;
                return dt;
            }
            catch (NullReferenceException ex)
            {
                Response.Write("2. " + ex.Message + "。");
                //Response.End();
                return new DataTable();
            }
        }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:31,代码来源:ProvinceManage.aspx.cs

示例3: del

 public static void del(string id)
 {
     SQLHelper.DeleteEntity<DXLb>(id);
     SQLHelper db = new SQLHelper();
     db.sql = "UPDATE lb SET isDeleted=1 WHERE id="+id;
     db.ExecSql();
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:7,代码来源:clsLB.cs

示例4: getNewsDt

 public DataTable getNewsDt()
 {
     productid = hlbid.Value;
     SQLHelper db = new SQLHelper();
     string pagesize = Pager0.PageSize.ToString();
     string curpage = pg.request(Pager0.PagePara);
     string pageCount = "";//总页数
     int rowCount = 0;
     if (pagesize == "") pagesize = "20";
     if (curpage == "") curpage = "1";
     string sql = @"SELECT c.imgTypeName,b.ColorValue,b.ColorName
     ,SUBSTRING((''000''+CONVERT(varchar,b.OrderId)),LEN(''000''+CONVERT(varchar,b.OrderId))-2,3)+''-''+b.ColorName AS ColorText
     ,a.*
     FROM "[email protected]"News a LEFT JOIN "[email protected]"Color b ON a.colorId=b.id
     LEFT JOIN "[email protected]"ProductImgType c ON c.id =a.pro_imgTypeid
     WHERE a.ParentNewsID=" + productid;
     sql += " ORDER BY a.OrderId";
     sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
     db.sql = sql;
     DataSet ds = db.Get_DataSet();
     DataTable dt = ds.Tables[2];
     pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
     rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
     Pager0.RecordCount = rowCount;
     if (rowCount == 0) Pager0.Visible = false;
     return dt;
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:27,代码来源:ProPicManage.aspx.cs

示例5: btnRun_Click

 protected void btnRun_Click(object sender, EventArgs e)
 {
     string sql = tbxSql.Text.Trim().ToUpper();
     SQLHelper db = new SQLHelper();
     db.sql = sql;
     if (sql.Contains("SELECT "))
     {
         DataTable dt = db.Get_DataTable();
         gv.DataSource = dt;
         gv.DataBind();
         lblMsg.Text = "执行完成,查询结果如下:";
     }
     else
     {
         string result = db.ExecSql();
         if (result == "1")
         {
             lblMsg.Text = "执行完成";
         }
         else
         {
             lblMsg.Text = "执行失败," + result;
         }
     }
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:25,代码来源:execSql.aspx.cs

示例6: bindGv

 public void bindGv(bool addNewRow)
 {
     lbid = hlbid.Value;
     SQLHelper db = new SQLHelper();
     string pagesize = Pager2.PageSize.ToString();
     string curpage = pg.request(Pager2.PagePara);
     string pageCount = "";//总页数
     int rowCount = 0;
     if (pagesize == "") pagesize = "5";
     if (curpage == "") curpage = "1";
     string sql = @"SELECT *
     FROM "[email protected]"News
     WHERE lbid=" + lbid;
     sql += " ORDER BY isTop DESC,IsIndex DESC,EditTime DESC";
     sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
     db.sql = sql;
     DataSet ds = db.Get_DataSet();
     DataTable dt = ds.Tables[2];
     pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
     rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
     Pager2.RecordCount = rowCount;
     if (rowCount == 0) Pager2.Visible = false;
     if (addNewRow)
     {
         DataRow newRow = dt.NewRow();
         dt.Rows.Add(newRow);
     }
     GV.DataSource = dt.DefaultView;
     GV.DataBind();
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:30,代码来源:VideoManage.aspx.cs

示例7: CreateDatabase

 /// <summary>
 /// Creates a database out of the structure it is given
 /// </summary>
 /// <param name="Database">Database structure</param>
 /// <param name="ConnectionString">The connection string to the database's location</param>
 public static void CreateDatabase(Database Database, string ConnectionString)
 {
     string Command = BuildCommands(Database);
     string[] Splitter = { "\n" };
     string[] Commands = Command.Split(Splitter, StringSplitOptions.RemoveEmptyEntries);
     ConnectionString = Regex.Replace(ConnectionString, "Pooling=(.*?;)", "", RegexOptions.IgnoreCase) + ";Pooling=false;";
     string DatabaseConnectionString = Regex.Replace(ConnectionString, "Initial Catalog=(.*?;)", "", RegexOptions.IgnoreCase);
     using (SQLHelper Helper = new SQLHelper(Commands[0], DatabaseConnectionString, CommandType.Text))
     {
         Helper.ExecuteNonQuery();
     }
     using (SQLHelper Helper = new SQLHelper("", ConnectionString, CommandType.Text))
     {
         try
         {
             Helper.BeginTransaction();
             for (int x = 1; x < Commands.Length; ++x)
             {
                 Helper.Command = Commands[x];
                 Helper.ExecuteNonQuery();
             }
             Helper.Commit();
         }
         catch { Helper.Rollback(); throw; }
     }
 }
开发者ID:yiwayhb,项目名称:Craig-s-Utility-Library,代码行数:31,代码来源:SQLServer.cs

示例8: PeptideDAL

        public PeptideDAL(string sDataBase)
        {
            string sServer = "10.60.43.39";
            string sUid = "root";
            string sPwd = "root";
            string sMySqlConnString = string.Format("Server={0};Database={1};Uid={2};Pwd={3};Persist Security Info=True;Pooling=False;", sServer, sDataBase, sUid, sPwd);
            sqlHelper = new SQLHelper(sMySqlConnString);

            lstColName.Add("ID");
            lstColName.Add("AC");
            lstColName.Add("DT");
            lstColName.Add("DE");
            lstColName.Add("GN");
            lstColName.Add("OS");
            lstColName.Add("OC");
            lstColName.Add("OX");
            lstColName.Add("RN");
            lstColName.Add("RP");
            lstColName.Add("RX");
            lstColName.Add("RA");
            lstColName.Add("RT");
            lstColName.Add("RL");
            lstColName.Add("RC");
            lstColName.Add("RG");
            lstColName.Add("CC");
            lstColName.Add("DR");
            lstColName.Add("PE");
            lstColName.Add("KW");
            lstColName.Add("FT");
            lstColName.Add("SQ");
            lstColName.Add("ModResSingle");
        }
开发者ID:jingpeng,项目名称:protein-goggle-search-core,代码行数:32,代码来源:PeptideDAL.cs

示例9: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
           string folderLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "jobTracker");
            string dbLocation = Path.Combine(folderLocation,"jobTrackerDB.sqlite");
             sqlHelper = new SQLHelper(dbLocation);

             if (!File.Exists(dbLocation))
             {
                 sqlHelper.createDB();
                 sqlHelper.createTable("jobs", createJobsTable.getJobsbasicInfo());
             }

             dataLocation = dbLocation;
           

            txtExportLocation.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

           var jobsColumns = sqlHelper.getColumnNames("jobs");

           foreach (string s in jobsColumns)
           {
               listViewDisplay.Columns.Add(s);
           }
          
            updateList();


            
            

        }
开发者ID:GabrielSamp,项目名称:.Net-Programs,代码行数:31,代码来源:JobTrackerMain.cs

示例10: getNewsDt

 public DataTable getNewsDt()
 {
     SQLHelper db = new SQLHelper();
     try
     {
         string pagesize = Pager1.PageSize.ToString();
         string curpage = pg.request(Pager1.PagePara);
         string pageCount = "";//总页数
         int rowCount = 0;
         if (pagesize == "") pagesize = "15";
         if (curpage == "") curpage = "1";
         string sql = @"SELECT id,ColorName,ColorValue,SUBSTRING((''000''+CONVERT(varchar,OrderId)),LEN(''000''+CONVERT(varchar,OrderId))-3,4) AS OrderId FROM " + com.tablePrefix + "Color ORDER BY OrderId";
         sql = "exec sp_GetPageData '" + sql + "'," + curpage + "," + pagesize;
         db.sql = sql;
         DataSet ds = db.Get_DataSet();
         DataTable dt = ds.Tables[2];
         pageCount = ds.Tables[1].Rows[0]["COUNTPAGE"].ToString();
         rowCount = Int32.Parse(ds.Tables[1].Rows[0]["ROWCOUNT"].ToString());
         Pager1.RecordCount = rowCount;
         if (rowCount == 0) Pager1.Visible = false;
         return dt;
     }
     catch (Exception ex)
     {
         Response.Write("2. " + ex.Message + "。");
         //Response.End();
         return null;
     }
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:29,代码来源:ColorManage.aspx.cs

示例11: AdminInfo

 public static DataTable AdminInfo(int id)
 {
     string sql = "SELECT * FROM " + com.tablePrefix + "Admin WHERE id=" + id.ToString() + "";
     SQLHelper db = new SQLHelper();
     db.sql = sql;
     return db.Get_DataTable();
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:7,代码来源:clsAdmin.cs

示例12: GetMaxItemID

    /// <summary>
    /// 得到當前最大ToDo Item ID
    /// </summary>
    /// <returns></returns>
    private string GetMaxItemID(SQLHelper conn, string user_id, out int mySeq)
    {
        string rtn = "";
        mySeq = 0;

        string matchString = GetMatchString("D");
        DataTable table = conn.OpenDataTable("select isnull(max(td_no),'') as maxid from lrtd00h (nolock) where td_no like '" + matchString + "%'", CommandType.Text);
        if (table.Rows.Count > 0)
        {
            rtn = table.Rows[0][0].ToString();
        }

        table = conn.OpenDataTable("select isnull(max(td_seq),0) as maxid from lrtd00h (nolock) where td_owner= '" + user_id + "'", CommandType.Text);

        if (table.Rows.Count > 0)
        {
            mySeq = Convert.ToInt32(table.Rows[0][0]);
        }
        else
        {
            mySeq = 0;
        }

        // 只留下流水號
        rtn = rtn.Replace(matchString, "");
        if (rtn == "")
            rtn = "00000";

        return rtn;
    }
开发者ID:Donnie888,项目名称:LxServer,代码行数:34,代码来源:ToDoManagerService.cs

示例13: bindFunctionList

        protected void bindFunctionList()
        {
            functionList.Items.Clear();
            //for (int i = 1; i <= 35; i++)
            //{
            //    ListItem li = new ListItem();
            //    string img = "0" + i.ToString() + ".jpg";
            //    int len = img.Length;
            //    img = img.Substring(len - 6, 6);
            //    li.Value = img;
            //    li.Text = "<img src='../images/function_icon/" + img + "' />";
            //    functionList.Items.Add(li);
            //}

            SQLHelper db = new SQLHelper();
            db.sql = "SELECT NewsId,Title,Description,pic FROM " + com.tablePrefix + "News WHERE lbid=64";
            DataTable dt = db.Get_DataTable();
            functionList.DataSource = dt;
            foreach (DataRow dr in dt.Rows)
            {
                ListItem li = new ListItem();
                li.Value = dr["NewsId"].ToString();
                li.Text = "<img src='" + dr["pic"].ToString() + "' title='" + dr["Description"].ToString() + "' />";
                functionList.Items.Add(li);
            }
        }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:26,代码来源:ProAdd.aspx.cs

示例14: bindProPlb

 protected void bindProPlb()
 {
     SQLHelper db = new SQLHelper();
     db.sql = "SELECT lbid,lbname FROM " + com.tablePrefix + "lb WHERE parentid=4 Order By OrderId";
     DataTable dt = db.Get_DataTable();
     rptProLbParent.DataSource = dt;
     rptProLbParent.DataBind();
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:8,代码来源:LeftMenu.aspx.cs

示例15: AddLb

 /// <summary>
 /// 添加栏目
 /// </summary>
 /// <param name="lbname">栏目名称</param>
 /// <param name="parentid">父栏目ID</param>
 /// <returns>int,1=成功,0=已存在</returns>
 public static string AddLb(string lbname, string parentid)
 {
     string maxlbid = MaxLbid();
     string sql = "INSERT INTO " + com.tablePrefix + "lb (lbid,lbname,parentid,OrderId) VALUES(" + maxlbid + ",'" + lbname + "'," + parentid + "," + maxlbid + ")";
     SQLHelper db = new SQLHelper();
     db.sql = sql;
     return db.ExecSql();
 }
开发者ID:uwitec,项目名称:dx-shopsys,代码行数:14,代码来源:clsLB.cs


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