Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:23:55+00:00 2026-06-12T12:23:55+00:00

i am beginner in c# and using three layer programming. i can not update

  • 0

i am beginner in c# and using three layer programming. i can not update or delete records via data grid view. following is my codes. please help me.

DAl

 namespace DAL
    {
        public class TblkalaDal
        {
            SqlConnection cn=new SqlConnection("Data Source=(local); Initial Catalog=store;Integrated Security=True");
            public DataTable Getdata()
            {
                try
                {
                    DataSet ds=new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter("Sptblkala_getdata",cn);
                    da.SelectCommand.CommandType = CommandType.StoredProcedure;
                    da.Fill(ds, "Sptblkala_getdata");
                    return ds.Tables["Sptblkala_getdata"];
                }
                catch (Exception)
                {
                    return null;
                    throw;
                }
            }
    public string createkala(int kala_id,string kala_name,int kala_qty,int kala_orderpoint)
    {
        try
        {
            SqlCommand cmd = new SqlCommand("Sptblkala_insert", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@kala_id", kala_id);
            cmd.Parameters.AddWithValue("@kala_name", kala_name);
            cmd.Parameters.AddWithValue("@kala_qty", kala_qty);
            cmd.Parameters.AddWithValue("@kala_orderpoint", kala_orderpoint);
            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
            return "true";
        }
        catch (Exception ex)
        {
            return ex.Message;
            throw;
        }

    }
            public string Deletekala(int kala_id)
            {
                try
                {
                    SqlCommand dm = new SqlCommand("Sptblkala_delete", cn);
                    dm.CommandType = CommandType.StoredProcedure;
                    dm.Parameters.AddWithValue("@kala_id", kala_id);
                    cn.Open();
                    dm.ExecuteNonQuery();
                    cn.Close();
                    return "true";
                }
                catch (Exception ex)
                {
                 return   ex.Message;
                    throw;
                }

            }

            public string updatekala(int kala_id,string kala_name,int kala_qty,int kala_orderpoint)
            {
                try
                {
                    SqlCommand uk = new SqlCommand("Sptblkala_update", cn);
                    uk.CommandType = CommandType.StoredProcedure;
                    uk.Parameters.AddWithValue("@kala_id", kala_id);
                    uk.Parameters.AddWithValue("@kala_name", kala_name);
                    uk.Parameters.AddWithValue("@kala_qty", kala_qty);
                    uk.Parameters.AddWithValue("@kala_orderpoint", kala_orderpoint);
                    cn.Open();
                    uk.ExecuteNonQuery();
                    cn.Close();
                    return "true";
                }
                catch (Exception)
                {

                    throw;
                }
            }
        }
    }

BLL

namespace BLL
{
    public class bllkala
    {
        TblkalaDal tk=new TblkalaDal();
        public string createkala(int kala_id,string kala_name,int kala_qty,int kala_orderpoint)
        {
            return tk.createkala(kala_id, kala_name, kala_qty, kala_orderpoint);
        }
        public string deletekala(int kala_id)
        {
            return tk.Deletekala(kala_id);
        }
        public string updatekala(int kala_id,string kala_name,int kala_qty,int kala_orderpoint)
        {
            return tk.updatekala(kala_id, kala_name, kala_qty, kala_orderpoint);
        }
        public DataTable Getdata()
        {
          return  tk.Getdata();
        }
    }
}

presentation

namespace store
{
    public partial class kala : Form
    {
        public kala()
        {
            InitializeComponent();
        }

       bllkala bk=new bllkala();
        DataTable dt=new DataTable();

        private void btnkalainsert_Click(object sender, EventArgs e)
        {
            string check = bk.createkala(int.Parse(txtkalacode.Text), txtkalaname.Text, int.Parse(txtkqty.Text),
                                         int.Parse(txtkalapoint.Text));
            if (check=="true")
            {
                dt = bk.Getdata();
                dataGridViewkala.DataSource = dt;
            }
            else
            {
                MessageBox.Show(check);
            }
        }

        private void kala_Load(object sender, EventArgs e)
        {
            dt = bk.Getdata();
            dataGridViewkala.DataSource = dt;
        }

        private void btnkaladel_Click(object sender, EventArgs e)
        {
            dataGridViewkala.Rows.RemoveAt(dataGridViewkala.CurrentRow.Index);
            dt = bk.deletekala(int.Parse(txtkalacode.Text));
            dataGridViewkala.DataSource = dt;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:23:56+00:00Added an answer on June 12, 2026 at 12:23 pm

    i found the codes in presentation layer:

    private void btnkaladel_Click(object sender, EventArgs e)
            {
                if (MessageBox.Show("Are you sure to delete?", "Deleting...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
    
                    dataGridViewkala.Rows.RemoveAt(dataGridViewkala.CurrentRow.Index);
                    bk.deletekala(int.Parse(txtkalacode.Text));
                    dataGridViewkala.DataSource = dt;
                    txtkalacode.Text = null;
                    txtkalaname.Text = null;
                    txtkalapoint.Text = null;
                    txtkqty.Text = null;
                }
            }
    
    
    
            private void dataGridViewkala_CellClick(object sender, DataGridViewCellEventArgs e)
            {
                txtkalacode.Text = dataGridViewkala.Rows[e.RowIndex].Cells[0].Value.ToString();
                txtkalaname.Text = dataGridViewkala.Rows[e.RowIndex].Cells[1].Value.ToString();
                txtkqty.Text = dataGridViewkala.Rows[e.RowIndex].Cells[2].Value.ToString();
                txtkalapoint.Text = dataGridViewkala.Rows[e.RowIndex].Cells[3].Value.ToString();
            }
    
            private void btnedit_Click(object sender, EventArgs e)
            {
                if (MessageBox.Show("Are you sure to edit?", "editing...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    bk.updatekala(int.Parse(txtkalacode.Text), txtkalaname.Text, int.Parse(txtkqty.Text),
                                  int.Parse(txtkalapoint.Text));
                    dt = bk.Getdata();
                    dataGridViewkala.DataSource = dt;
                    txtkalacode.Text = null;
                    txtkalaname.Text = null;
                    txtkalapoint.Text = null;
                    txtkqty.Text = null;
                }
            }
    
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a beginner in using Blend and WPF in general. I created three
im a beginner in using solr. i know that you can either use ajax
I am beginner at using JSP and am following a tutorial. I have a
Is there an easy beginner way to take the current time using <ctime> to
EDIT: The plugin in question is located here . PHP beginner here using a
I'm a RoR beginner and am using Rails 3.2.3. I have a search form
I am a beginner when it comes to using mysql queries embedded inside other
I'm a Python beginner and have just started using packages. When you're calling a
I am a beginner to php and mySQL and I am currently using dreamweaver
I am a beginner programmer, using python on Mac. I created a function as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.