不将数据输入数据库 [英] Not Entering the data into the datbase

查看:59
本文介绍了不将数据输入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在我的项目中,我添加了一个网页ConferenceRoom,因为我正在输入与之相关的数据,但我输入的数据未在数据库中显示.您能帮我吗?我正在张贴我使用的代码.

hi all,

in my project i added one webpage ConferenceRoom in that i am entering the data related to it but that data i am entering is not getting displayed in database.can u please help me.i am posting the code what i used.

public partial class HRMSNewConferenceRoom : System.Web.UI.Page
{

    #region Global Declaration
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            BindPjctEmployees();
            ddlEmployeeName.Visible = true;
            btnSave.Visible = true;
            btnCancel.Visible = true;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            ConferenceBM confBM = new ConferenceBM();
            ConferenceBL confBL = new ConferenceBL();

            confBM.EmployeeName = ddlEmployeeName.SelectedItem.Text;
            confBM.PurposeOfBooking = txtPurpose.Text;
            confBM.StartDate = Convert.ToDateTime(txtStartDate.Text);
            confBM.EndDate = Convert.ToDateTime(txtEndDate.Text);
            confBM.StartTime = Convert.ToDateTime(txtStartTime.Text);
            confBM.EndTime = Convert.ToDateTime(txtEndTime.Text);
            confBM.ConferenceRoom = dd1conference.SelectedItem.Text;

            ClientScript.RegisterClientScriptBlock(this.GetType(), "AlertWindow", "<script language='Javascript'>alert('ConferenceRoom Booked Successfully'); </script>");


        }

        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }

        }
    }

    private void BindPjctEmployees()
    {
        TimeSheetBL timeSheetBL = new TimeSheetBL();
        EmpBL empBL = new EmpBL();
        DataSet ds;

        ProjectsBL pjctBL = new ProjectsBL();
        int roleID = pjctBL.GetemployeeRole((string)Session["EmployeeID"]);

        ds = empBL.GetAllEmployees();
        ddlEmployeeName.DataSource = ds;
        ddlEmployeeName.DataTextField = "FullName";
        ddlEmployeeName.DataBind();
        ddlEmployeeName.Items.Insert(0, "--All Employees--");
    }

   }


请建议我该怎么做?


please suggest me what i need to do?

推荐答案

您实际上并没有在任何地方调用save吗?

在btnSave_Click中,您将根据ConferenceBM类型创建一个对象并为其分配值.但是您还没有坚持这个对象!

例如您需要像...一样使用ConferenceBL ...

You''re not actually calling save anywhere though are you?

In btnSave_Click, you''re creating an object from type ConferenceBM and assigning values to it. But you haven''t persisted this object!

e.g. you need to use your ConferenceBL like...

confBL.SaveConferenceDetails(confBM);



(或您创建的任何方法都可以调用此对象类型的数据库)



(or whatever method you''ve created that makes the call to the database for this object type)


您的片段中似乎没有任何与数据库相关的代码.您是否忘记了在btnSave_Click方法中保存任何内容?
You don''t appear to have any database related code in your fragment. Did you forget to save anything in the btnSave_Click method?


您没有保存它,因此它不会显示在数据库中. confBM(或congBL,在您的代码中未使用)应具有Save方法,并且必须调用它.
You don''t save it, so it''s not displayed in database. confBM (or congBL, which is unused in your code) should have Save method and you have to call it.


这篇关于不将数据输入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆