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


C# DbConnection.DbConn方法代码示例

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


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

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        //DbConnection 인스턴스 초기화
        DbConnection DbConn = new DbConnection();
        SqlConnection conn = DbConn.DbConn();

        ////프로시저명 
        //string SpName = "SP_BoardList";
        //SqlCommand cmd = new SqlCommand(SpName, conn);
        //cmd.CommandType = CommandType.StoredProcedure;

        ////SqlDataReader 사용
        //SqlDataReader objDr = cmd.ExecuteReader();
        //this.List.DataSource = objDr;
        //this.List.DataBind();

        //SqlDataAdapter 사용
        SqlDataAdapter da = new SqlDataAdapter("SP_BoardList", conn);
        da.SelectCommand.CommandType = CommandType.StoredProcedure;

        //DataSet 사용
        DataSet ds = new DataSet();
        da.Fill(ds, "BoardList");
        List.DataSource = ds;
        List.DataBind();
    }
开发者ID:changjik,项目名称:mosti_board,代码行数:26,代码来源:BoardList.aspx.cs

示例2: getView

    protected void getView()
    {
        //DbConnection 인스턴스 초기화
        DbConnection DbConn = new DbConnection();
        SqlConnection conn = DbConn.DbConn();

        //프로시저명 
        string SpName = "SP_BoardView";
        SqlCommand cmd = new SqlCommand(SpName, conn);
        cmd.CommandType = CommandType.StoredProcedure;

        //파라미터 설정
        cmd.Parameters.Add("@PK_BoardList", SqlDbType.Int);
        cmd.Parameters["@PK_BoardList"].Value = Convert.ToInt32(Request.QueryString["ID"].ToString());

        SqlDataReader objDr = cmd.ExecuteReader();

        while(objDr.Read()){
            lblKorName.Text = objDr[1].ToString();
            lblEngName.Text = objDr[2].ToString();
            lblJumin1.Text = objDr[3].ToString().Substring(0, 6);
            lblJumin2.Text = objDr[3].ToString().Substring(6);

            string BirthdayStr = objDr[4].ToString();
            lblBirthday.Text = BirthdayStr.Substring(0, 4) + "년 " + BirthdayStr.Substring(4, 2) + "월 " + BirthdayStr.Substring(6) + "일";

            if (objDr[5].ToString().Equals(1))
            {
                chkLunar.Checked = true;
            }
            else
            {
                chkLunar.Checked = false;
            }

            lblRepNo.Text = objDr[6].ToString().Substring(0, 3);
            lblTelMiddleNo.Text = objDr[6].ToString().Substring(3, 4);
            lblTelLastNo.Text = objDr[6].ToString().Substring(7);

            string sexType = objDr[7].ToString();
            if (objDr[7].ToString().Equals("M"))
            {
                lblSex.Text = sexType.Replace(objDr[7].ToString(), "남");
            }
            else
            {
                lblSex.Text = sexType.Replace(objDr[7].ToString(), "여");
            }

            lblReligion.Text = objDr[8].ToString();
            lblMilitaryType.Text = objDr[9].ToString();
            txtRemark.Text = objDr[10].ToString();

        }
    }
开发者ID:changjik,项目名称:mosti_board,代码行数:55,代码来源:BoardView.aspx.cs

示例3: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            //DbConnection 인스턴스 초기화
            DbConnection DbConn = new DbConnection();
            SqlConnection conn = DbConn.DbConn();

            //대표변호 프로시저
            SqlCommand cmdRepNo = new SqlCommand("SP_RepNo", conn);
            cmdRepNo.CommandType = CommandType.StoredProcedure;

            //Dropdownlist value 바인딩
            SqlDataReader objDr = cmdRepNo.ExecuteReader();
            ddlRepNo.DataSource = objDr;
            ddlRepNo.DataTextField = "CODE_NM";
            ddlRepNo.DataValueField = "CODE";
            ddlRepNo.DataBind();
            objDr.Close();

            //종교 프로시저
            SqlCommand cmdReligion = new SqlCommand("SP_Religion", conn);
            cmdReligion.CommandType = CommandType.StoredProcedure;

            objDr = cmdReligion.ExecuteReader();
            ddlReligion.DataSource = objDr;
            ddlReligion.DataTextField = "CODE_NM";
            ddlReligion.DataValueField = "CODE";
            ddlReligion.DataBind();
            objDr.Close();

            //군별 프로시저
            SqlCommand cmdMilitaryType = new SqlCommand("SP_MilitaryType", conn);
            cmdMilitaryType.CommandType = CommandType.StoredProcedure;

            objDr = cmdMilitaryType.ExecuteReader();
            ddlMilitaryType.DataSource = objDr;
            ddlMilitaryType.DataTextField = "CODE_NM";
            ddlMilitaryType.DataValueField = "CODE";
            ddlMilitaryType.DataBind();
            objDr.Close();

            ddlMilitaryType.Items.Insert(0, "해당없음");
        }
       
    }
开发者ID:changjik,项目名称:mosti_board,代码行数:46,代码来源:BoardWrite.aspx.cs

示例4: btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e)
    {
        //DbConnection 인스턴스 초기화
        DbConnection DbConn = new DbConnection();
        SqlConnection conn = DbConn.DbConn();

        ////프로시저명 
        string SpName = "SP_BoardWrite";
        SqlCommand cmd = new SqlCommand(SpName, conn);
        cmd.CommandType = CommandType.StoredProcedure;

        //파라미터 설정
        cmd.Parameters.Add("@NM_KOR", SqlDbType.NVarChar, 10);
        cmd.Parameters.Add("@NM_ENG", SqlDbType.NVarChar, 100);
        cmd.Parameters.Add("@Jumin_NO", SqlDbType.Char, 13);
        cmd.Parameters.Add("@Birthday", SqlDbType.VarChar, 8);
        cmd.Parameters.Add("@Lunar_CHK", SqlDbType.Bit);
        cmd.Parameters.Add("@Phone_NO", SqlDbType.VarChar, 11);
        cmd.Parameters.Add("@Sex", SqlDbType.Char, 1);
        cmd.Parameters.Add("@Religion", SqlDbType.VarChar, 4);
        cmd.Parameters.Add("@Military_TYPE", SqlDbType.VarChar, 4);
        cmd.Parameters.Add("@Remark", SqlDbType.NVarChar, 1000);

        cmd.Parameters["@NM_KOR"].Value = txtKorName.Text;
        cmd.Parameters["@NM_ENG"].Value = txtEngName.Text;
        cmd.Parameters["@Jumin_NO"].Value = txtJumin1.Text + txtJumin2.Text;
        cmd.Parameters["@Birthday"].Value = txtBirthday.Text;
        cmd.Parameters["@Lunar_CHK"].Value = chkLunar.Checked;
        cmd.Parameters["@Phone_NO"].Value = ddlRepNo.SelectedItem.Text + txtTelMiddleNo.Text + txtTelLastNo.Text;
        cmd.Parameters["@Sex"].Value = RadioBtnSex.SelectedValue;
        cmd.Parameters["@Religion"].Value = ddlReligion.SelectedValue;
        cmd.Parameters["@Military_TYPE"].Value = ddlMilitaryType.SelectedValue;
        cmd.Parameters["@Remark"].Value = txtRemark.Text;

        cmd.ExecuteNonQuery();
        conn.Close();

        cmd = null;

        string script = "<script>alert('저장되었습니다');</script>";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "saveScript", script);
        Response.Redirect("BoardList.aspx");

    }
开发者ID:changjik,项目名称:mosti_board,代码行数:44,代码来源:BoardWrite.aspx.cs


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