hi can anyone help me with checkbox binding in c# to sql database if data is in bit format and to retrieve the same from database

What do you have so far? what exactly is that you stuck with?

here is the code that i have done so far.But i m unable to view data using the next button, please anyone can see what m i doing wrong or give me some new ideas.and also this is my first project, so please bare with me.........

private void roommaster_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = "Data source=SID\\SQLEXPRESS;Initial Catalog=Taj - Hotel Management;Integrated Security=True";

            con.Open();
            string sql = "select * from RoomMaster";

            da = new SqlDataAdapter(sql, con);
            SqlCommandBuilder bldr = new SqlCommandBuilder(da);

            ds = new DataSet();
            da.Fill(ds, "RoomMaster");

            bmgr = this.BindingContext[ds, "RoomMaster"];

            txt_RoomNo.DataBindings.Add("Text", ds, "RoomMaster.RoomNo");
            txt_ResourceID.DataBindings.Add("Text", ds, "RoomMaster.ResourceID");
            txt_RoomType.DataBindings.Add("Text", ds, "RoomMaster.RoomType");

            combox_RoomView.DataSource = ds;
            combox_RoomView.DisplayMember = "RoomMaster.RoomView";
            cbox_ActiveFlag.DataBindings.Add("Checked", ds, "RoomMaster.ActiveFlag");
            Cbox_BookedFlag.DataBindings.Add("Checked", ds, "RoomMaster.BookedFlag");
            cbox_ProcessFlag.DataBindings.Add("Checked", ds, "RoomMaster.ProcessFlag");
                
           

        }

        private void btn_ADD_Click(object sender, EventArgs e)
        {
            txt_RoomType.Text = "";
            txt_RoomNo.Text = "";
            txt_ResourceID.Text = "";
            cbox_ActiveFlag.Checked = false;
            Cbox_BookedFlag.Checked = false;
            cbox_ProcessFlag.Checked = false;





            int ctr, len;
            string codeval;
            dt = ds.Tables["RoomMaster"];

            len = dt.Rows.Count-1;

            dr = dt.Rows[len];

            code = dr["RoomNo"].ToString();
            codeval = code.Substring(1, 3);
            ctr = Convert.ToInt32(codeval);

            if ((ctr >= 1) && (ctr < 9))
            {
                ctr = ctr + 1;
                txt_RoomNo.Text = "000" + ctr;
            }
            else if ((ctr >= 9) && (ctr < 99))
            {
                ctr = ctr + 1;
                txt_RoomNo.Text = "00" + ctr;
            }
            else if ((ctr >= 99) && (ctr < 999))
            {
                ctr = ctr + 1;
                txt_RoomNo.Text = "0" + ctr;
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            dt = ds.Tables["RoomMaster"];
            dr = dt.NewRow();
            dr[0] = txt_RoomNo.Text;
            dr[1] = txt_ResourceID.Text;
            dr[2] = txt_RoomType.Text;

            if (Cbox_BookedFlag.Checked == true)
            {
                dr[3] = Cbox_BookedFlag.Checked;
            }

           if (cbox_ActiveFlag.Checked == true)
            {
                dr[4] = cbox_ActiveFlag.Checked;
            }

            if (cbox_ProcessFlag.Checked == true)
            {
                dr[5] = cbox_ProcessFlag.Checked;
            }


            dt.Rows.Add(dr);

            

            da.Update(ds, "RoomMaster");

            txt_RoomNo.Text = Convert.ToString(dr[0]);
            this.da.Fill(this.ds);
        }

        

        private void btn_next_Click_1(object sender, EventArgs e)
        {
            if (bmgr.Position == bmgr.Count - 1)
                MessageBox.Show("End of records");
            else
                bmgr.Position += 1;
        }
This article has been dead for over six months. Start a new discussion instead.