• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# DB类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SExecuteScalar

 public static object SExecuteScalar(string sql, params object[] parameter)
 {
     using (DB db = new DB())
     {
         return db.ExecuteScalar(sql, parameter);
     }
 }
开发者ID:nokitty,项目名称:chaxin,代码行数:7,代码来源:DB.cs


示例2: InsertDataBase

    //在数据表Resources插入一条记录操作
    protected bool InsertDataBase()
    {
        bool result = false;

        using (SqlConnection conn = new DB().GetConnection())
        {
            //向resources插入一条记录操作
            StringBuilder sb = new StringBuilder("Insert into Resources (ResourceName,FileName,FilePath,FileSizeInKB,FileType,Extentsion,FolderID,FolderName,UserID,CDT,Status,UserName)");
            sb.Append(" values(@ResourceName,@FileName,@FilePath,@FileSize,@FileType,@Extentsion,@FolderID,@FolderName,@UserID,@CDT,@Status,@UserName)");
            SqlCommand cmd = new SqlCommand(sb.ToString(), conn);
            //cmd.Parameters.AddWithValue("@ResourceName", TextBox1.Text);
            cmd.Parameters.AddWithValue("@ResourceName", TextBox1.Text.Trim());
            cmd.Parameters.AddWithValue("@FileName", FN.Text);
            cmd.Parameters.AddWithValue("@FilePath", FP.Text);
            cmd.Parameters.AddWithValue("@FileSize", FS.Text);
            cmd.Parameters.AddWithValue("@FileType", ResourceTypeLabel.Text);
            cmd.Parameters.AddWithValue("@Extentsion", FET.Text);
            cmd.Parameters.AddWithValue("@FolderID", 0);
            cmd.Parameters.AddWithValue("@FolderName", "");
            cmd.Parameters.AddWithValue("@UserID", Session["UserID"].ToString());
            cmd.Parameters.AddWithValue("@UserName", Session["UserName"].ToString());
            cmd.Parameters.AddWithValue("@CDT", DateTime.Now);
            cmd.Parameters.AddWithValue("@Status", 0);
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
            //插入成功
            result = true;
        }
        return result;
    }
开发者ID:ZRUIK,项目名称:SETC,代码行数:32,代码来源:File_Browse.aspx.cs


示例3: Save

        public bool Save(DB.Stru.事务科.专项救助_低保边缘户 stru)
        {
            string strID =  Orm.Save(stru);
            stru.ID = strID;

            return ! String.IsNullOrEmpty(strID);
        }
开发者ID:cheng521yun,项目名称:https---github.com-frontflag-FTMZ_CY,代码行数:7,代码来源:专项救助_低保边缘户.cs


示例4: Save

        public bool Save(DB.Stru.福利中心.老人费用退费管理 stru)
        {
            string strID =  Orm.Save(stru);
            stru.ID = strID;

            return ! String.IsNullOrEmpty(strID);
        }
开发者ID:cheng521yun,项目名称:FTMZ,代码行数:7,代码来源:老人费用退费管理.cs


示例5: getWorkInfo

		/**
		 * Fetches info needed from the database.
		 */
		private RevisionWorkInfo getWorkInfo(DB db, int revisionWorkID, int workID) {
			using (var cmd = db.CreateCommand ()) {
				cmd.CommandText = @"
					SELECT revision.revision, lane.id, lane.repository, lane.lane
					FROM revisionwork
					INNER JOIN revision ON revision.id = revisionwork.revision_id
					INNER JOIN lane ON lane.id = revision.lane_id
					WHERE revisionwork.id = @rwID;

					SELECT command.command
					FROM work
					INNER JOIN command ON command.id = work.command_id
					WHERE work.id = @wID
				";
				DB.CreateParameter (cmd, "rwID", revisionWorkID);
				DB.CreateParameter (cmd, "wID", workID);
				using (var reader = cmd.ExecuteReader ()) {
					RevisionWorkInfo info;

					reader.Read ();

					info.hash = reader.GetString (0);
					info.laneID = reader.GetInt32 (1);
					info.repoURL = reader.GetString (2);
					info.laneName = reader.GetString (3);

					reader.NextResult ();
					reader.Read ();

					info.command = reader.GetString (0);

					return info;
				}
			}
		}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:38,代码来源:GitHubNotification.cs


示例6: confirm_Click

 protected void confirm_Click(object sender, EventArgs e)///首先判断该人员是否已经安排过值班
 {
     DB db = new DB();
     string str = "SELECT jobskyerID FROM dutyTimeTable";
     string jobskyerID = chooseName.SelectedValue;
     SqlConnection con = new SqlConnection();
     con = db.GetCon();
     SqlCommand com = new SqlCommand(str, con);
     SqlDataAdapter da = new SqlDataAdapter(com);
     DataSet ds = new DataSet();
     da.Fill(ds);
     ///SqlDataReader dr = com.ExecuteReader();
     int k = ds.Tables[0].Rows.Count;
     for (int i = 0; i < k; ++i)
     {
         if (jobskyerID == ds.Tables[0].Rows[i]["jobskyerID"].ToString())
         {
             Update_DutyTime();
         }
         if (i == k)
         {
             Insert_DutyTime();
         }
     }
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:25,代码来源:ManagerDutyTime.aspx.cs


示例7: Update_DutyTime

 public bool Update_DutyTime()///如果选择了安排过值班的人,就更新值班安排数据
 {
     DB db = new DB();
     string dutyInTime = chooseWeekday.SelectedValue + chooseSignInTime.SelectedValue;
     string dutyOutTime = chooseWeekday.SelectedValue + chooseSignOutTime.SelectedValue;
     string str = "UPDATE dutyTimeTable SET [email protected],[email protected] WHERE [email protected]";
     SqlConnection con = new SqlConnection();
     con = db.GetCon();
     SqlCommand com = new SqlCommand(str, con);
     com.Parameters.Add("@dutyInTime", SqlDbType.DateTime, 0).Value = dutyInTime;
     com.Parameters.Add("@dutyOutTime", SqlDbType.DateTime, 0).Value = dutyOutTime;
     com.Parameters.Add("@jobskyerID", SqlDbType.DateTime, 0).Value = chooseName.SelectedValue;
     try
     {
         com.ExecuteNonQuery();
         Sign_Result.Text = "更新值班成功!";
     }
     catch (Exception ex)
     {
         Sign_Result.Text = "更新值班失败!";
         return false;
     }
     finally
     {
         com.Dispose();
         con.Close();
     }
     return true;
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:29,代码来源:ManagerDutyTime.aspx.cs


示例8: GetJobName

 public string GetJobName(object jobskyerID)             //把jobskyerID转化为jobName输出
 {
     DB db = new DB();
     SqlDataReader dr = db.reDr("SELECT jobName FROM jobskyer WHERE jobskyerID='" + jobskyerID + "'");
     dr.Read();
     return dr.GetValue(0).ToString();
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:7,代码来源:JsManagerMain.aspx.cs


示例9: SetData

        public void SetData( DB.Stru.优抚科.优抚对象.伤残人员.基本信息 stru )
        {
            txt行政区划.Text = stru.行政区划;
            txt身份证号码.Text = stru.身份证号码 ;
            dat出生日期.strDate = stru.出生日期 ;
            cmb伤残等级.Text = stru.伤残等级 ;
            cmb伤残属别.Text = stru.伤残属别 ;
            dat参加工作时间.Text = stru.入伍时间 ;
            cmb劳动能力.Text = stru.劳动能力 ;
            cmb就业情况.Text = stru.就业情况 ;
            cmb户口簿住址类别.Text = stru.户口簿住址类别 ;

            txt姓名.Text = stru.姓名;
            cmb民族.Text = stru.民族;
            cmb性别.Text = stru.性别 ;
            cmb伤残性质.Text = stru.伤残性质;
            cmb婚姻状况.Text = stru.婚姻状况;
            dat退伍时间.strDate = stru.退伍时间 ;
            cmb生活能力.Text = stru.生活能力 ;
            cmb户口类别.Text = stru.户口类别 ;
            txt联系电话.Text = stru.联系电话 ;

            txt工作单位.Text = stru.工作单位 ;
            txt户口簿地址.Text = stru.户口簿住址 ;
            txt实际居住地地址.Text = stru.实际居住地址 ;
            txt备注.Text = stru.备注 ;
        }
开发者ID:cheng521yun,项目名称:https---github.com-frontflag-FTMZ_CY,代码行数:27,代码来源:伤残人员_基本信息.cs


示例10: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {
        int i = 0;
        using (SqlConnection conn = new DB().GetConnection())
        {
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = "Delete from SubMenu where ID in (" + IDSLabel.Text + ") ";
            conn.Open();
            i = cmd.ExecuteNonQuery();
            cmd.Dispose();

            cmd.CommandText = "select * from SubMenu where ID in (" + IDSLabel.Text + ") order by ID desc";
            SqlDataReader rd = cmd.ExecuteReader();
            GridView1.DataSource = rd;
            GridView1.DataBind();
            rd.Close();
            conn.Close();

        }
        if (i > 0)
        {
            ResultLabel.Text = "成功删除!";
            ResultLabel.ForeColor = System.Drawing.Color.Green;

        }
        else
        {
            ResultLabel.Text = "操作失败,请重试!";
            ResultLabel.ForeColor = System.Drawing.Color.Red;
        }
    }
开发者ID:ZRUIK,项目名称:SETC,代码行数:31,代码来源:SubMenu_Del.aspx.cs


示例11: Add_Update

        private bool Add_Update()
        {
            try
            {

                DB DataBase = new DB("Categories");

                DataBase.AddColumn("cat_name", Category_TB.Text.Trim());

                if(Category_Id == null)
                {
                    if(DataBase.IsNotExist("cat_id", "cat_name"))
                    {
                        return Confirm.Check(DataBase.Insert());
                    }
                    else
                    {
                        Message.Show("لقد تم تسجيل هذه الفئة من قبل", MessageBoxButton.OK, 5);
                        return false;
                    }


                }
                else
                {
                    DataBase.AddCondition("cat_id", this.Category_Id);
                    return Confirm.Check(DataBase.Update());
                }
            }
            catch
            {
                //MessageBox.Show("kiki_method");
                return false;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:35,代码来源:Categories.xaml.cs


示例12: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int RoleID = Convert.ToInt16(Session["RoleID"].ToString());

            if (Session["RoleID"] == null || Session["UserID"] == null)
            {
                Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx");
            }
            else if (RoleID > 1)
            {
                Util.ShowMessage("您没有访问该页面的权限!", "Login2.aspx");
            }
          else
          {
          UserName.Focus();
          using (SqlConnection conn = new DB().GetConnection())
          {
            string sql1 = "select * from Roles order by ID asc";
            SqlCommand cmd1 = new SqlCommand(sql1, conn);
            conn.Open();
            SqlDataReader rd1 = cmd1.ExecuteReader();
            Role.DataSource = rd1;
            Role.DataTextField = "RoleName";
            Role.DataValueField = "ID";
            Role.DataBind();
            rd1.Close();
          }
            }

        }
    }
开发者ID:ZRUIK,项目名称:SETC,代码行数:33,代码来源:User_Add.aspx.cs


示例13: clearLine

        protected string clearLine()
        {
            bool result = false;
            string line = Request.Form["line"];

            if (!string.IsNullOrEmpty(line) && line != "all")
            {
                using (DB db = new DB())
                {
                    List<DowntimeData> list = (from o in db.DowntimeDataSet
                                               where o.Client == "admin"
                                               && o.Line == line
                                               select o).ToList();

                    if (list.Count() > 0)
                    {
                        foreach (DowntimeData dt in list)
                        {
                            db.DeleteObject(dt);
                        }
                    }

                    result = db.SaveChanges() > 0;
                }
            }

            return result.ToString();
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:28,代码来源:TvDemoControl.aspx.cs


示例14: SInsert

 public static int SInsert(string sql, params object[] parameter)
 {
     using (DB db = new DB())
     {
         return db.Insert(sql, parameter);
     }
 }
开发者ID:nokitty,项目名称:chaxin,代码行数:7,代码来源:DB.cs


示例15: ScoreRankList_Bind

    public bool ScoreRankList_Bind()///下拉列表绑定数据
    {
        DB db = new DB();
        string sql_game = "SELECT * FROM GAME ";
        SqlConnection con = new SqlConnection();
        con = db.GetCon();
        con.Open();
        SqlCommand cmd = new SqlCommand(sql_game, con);
        SqlDataReader sqlRead_Game = cmd.ExecuteReader();
        try
        {
            ScoreRankList.DataSource = sqlRead_Game;
            ScoreRankList.DataTextField = "gamName";
            ScoreRankList.DataValueField = "gameID";
            ScoreRankList.DataBind();
            ScoreRankList.Items.Add(new ListItem("请选择","-1"));
            ScoreRankList.SelectedValue = "-1";

        }
        catch (Exception ex)
        {
            return false;
        }
        finally
        {
            cmd.Dispose();
            con.Close();
        }
        return true;
    }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:30,代码来源:ScoreRank.aspx.cs


示例16: GetData

        public bool GetData( ref DB.Stru.优抚科.优抚对象.伤残人员.基本信息 stru )
        {
            if ( !CheckBeforeSave() )
                return false;

            stru.行政区划 = txt行政区划.Text.Trim();
            stru.身份证号码 = txt身份证号码.Text.Trim();
            stru.出生日期 = dat出生日期.strDate;
            stru.伤残等级 = cmb伤残等级.Text.Trim();
            stru.伤残属别 = cmb伤残属别.Text.Trim();
            stru.入伍时间 = dat参加工作时间.Text.Trim();
            stru.劳动能力 = cmb劳动能力.Text.Trim();
            stru.就业情况 = cmb就业情况.Text.Trim();
            stru.户口簿住址类别 = cmb户口簿住址类别.Text.Trim();

            stru.姓名 = txt姓名.Text.Trim();
            stru.民族 = cmb民族.Text.Trim();
            stru.性别 = cmb性别.Text.Trim();
            stru.伤残性质 = cmb伤残性质.Text.Trim();
            stru.婚姻状况 = cmb婚姻状况.Text.Trim();
            stru.退伍时间 = dat退伍时间.strDate;
            stru.生活能力 = cmb生活能力.Text.Trim();
            stru.户口类别 = cmb户口类别.Text.Trim();
            stru.联系电话 = txt联系电话.Text.Trim();

            stru.工作单位 = txt工作单位.Text.Trim();
            stru.户口簿住址 = txt户口簿地址.Text.Trim();
            stru.实际居住地址 = txt实际居住地地址.Text.Trim();
            stru.备注 = txt备注.Text.Trim();

            return true;
        }
开发者ID:cheng521yun,项目名称:https---github.com-frontflag-FTMZ_CY,代码行数:32,代码来源:伤残人员_基本信息.cs


示例17: ScoreRank_Bind

 public bool ScoreRank_Bind()///分数排行绑定数据
 {
     DB db = new DB();
     string scoreRankstr = "SELECT GAME_RECORD.jobskyerID,gamScore,jobName FROM GAME_RECORD,JOBSKYER WHERE GAME_RECORD.jobskyerID=JOBSKYER.jobskyerID ORDER BY gamScore desc";
     SqlConnection con = new SqlConnection();
     con = db.GetCon();
     con.Open();
     SqlCommand com = new SqlCommand(scoreRankstr, con);
     SqlDataReader dr = com.ExecuteReader();
     try
     {
         ScoreRank.DataSource = dr;
         ScoreRank.DataBind();
     }  
     catch(Exception ex)
     {
         return false;
     }  
     finally
     {
         com.Dispose();
         con.Close();
     }
     return true;
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:25,代码来源:ScoreRank.aspx.cs


示例18: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        if (State == null || State.Count <= 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "timeOut('../Default.aspx');", true); return; }

        DB db = new DB();
        string sql = "SELECT * FROM stock_images WHERE ";
        if (State["SelectedAppType"].ToString() == Constants.WEB_APP_TYPE || State["SelectedAppType"].ToString() == Constants.HYBRID_APP_TYPE)
            sql += "type='jquery_buttons' or type='blank_buttons'";
        else
            sql += "type='blank_buttons'";
        DataRow[] rows = db.ViziAppsExecuteSql(State, sql);
        DataSet paramsDS = new DataSet("ParameterDataSet");
        DataTable paramTable = paramsDS.Tables.Add("ParamTable");
        DataColumn paramCol = paramTable.Columns.Add("image_url", typeof(String));

        foreach (DataRow row in rows)
        {
            string type = row["type"].ToString();
            string url = row["image_url"].ToString();

            DataRow paramRow = paramTable.NewRow();
            string[] row_array = new string[1];
            row_array[0] = url;
            paramRow.ItemArray = row_array;
            paramTable.Rows.Add(paramRow);
        }

        ParamRepeater.DataSource = paramsDS;
        ParamRepeater.DataBind();
        db.CloseViziAppsDatabase((Hashtable)HttpRuntime.Cache[Session.SessionID]);
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:32,代码来源:ButtonColor.aspx.cs


示例19: Insert_DutyTime

 public bool Insert_DutyTime()///如果选择了没有安排过值班的人,就插入值班安排数据
 {
     string dutyInTime = chooseWeekday.SelectedValue + chooseSignInTime.SelectedValue;
     string dutyOutTime = chooseWeekday.SelectedValue + chooseSignOutTime.SelectedValue;
     string InsertStr = "INSERT INTO dutyTimeTable(dutyInTime,dutyOutTime,jobskyerID)VALUES(@dutyInTime,@dutyOutTime,@jobskyerID)";
     DB db = new DB();
     SqlConnection con = new SqlConnection();
     con = db.GetCon();
     con.Open();
     SqlCommand com = new SqlCommand(InsertStr, con);
     com.Parameters.Add("@dutyInTime", SqlDbType.DateTime, 0).Value = Convert.ToDateTime(dutyInTime);
     com.Parameters.Add("@dutyOutTime", SqlDbType.DateTime, 0).Value = Convert.ToDateTime(dutyOutTime);
     com.Parameters.Add("@jobskyerID", SqlDbType.NChar, 0).Value = chooseName.SelectedValue;
     try
     {
         com.ExecuteNonQuery();
         Sign_Result.Text = "安排值班成功!";
     }
     catch (Exception ex)
     {
         Sign_Result.Text = "安排值班失败!";
         return false;
     }
     finally
     {
         com.Dispose();
         con.Close();
     }
     return true;
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:30,代码来源:ManagerDutyTime.aspx.cs


示例20: ProcessResponse

    void ProcessResponse(string response)
    {
        if (response != "[]") {
            response = response.Trim (new Char[] { '{', '}' });
            string[] response_exploded = response.Split (',');

            DB db = new DB ();
            db.Connect ();

            foreach (string pair in response_exploded) {
                string[] key_value = pair.Split (':');
                string ext_id = key_value [1].Trim (new Char[]{'"'});
                string id = key_value [0].Trim (new Char[]{'"'});
                string query = "UPDATE participantes SET external_id = " + ext_id + " WHERE id = " + id;
                db.dbcmd.CommandText = query;
                if (db.dbcmd.ExecuteNonQuery () == 1) {
                    Debug.Log ("Exportado participante id local " + id + " a la id externa " + ext_id);
                }
            }

            db.Disconnect ();
        } else {
            Debug.Log ("No se exportó ningun participante nuevo");
        }

        GameObject.Find ("Button Export").GetComponent<Button> ().interactable = true;
    }
开发者ID:nskolaris,项目名称:bank-mobile-app,代码行数:27,代码来源:Export.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DBConnection类代码示例发布时间:2022-05-24
下一篇:
C# DATA_BLOB类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap