CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014
    Posts
    1

    Question Windows Form Application C# - Confirmation Message on Add, Edit, Delete?

    I have created a Windows C# Web Form Application in Visual Studio 2013 for adding, editing and deleting records in a database. I want to display a confirmation message whenever changes have been made to the database. What do I add and where do I add it? The code below is the opening part of the form and includes the insert query.

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    
    namespace somecityform
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
    
            }
    
            private void label2_Click(object sender, EventArgs e)
            {
    
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                SqlConnection con = new SqlConnection("Data Source=MY-PC;Initial Catalog=somecity;Integrated Security=True");
                con.Open();
                SqlCommand cmd = new SqlCommand("Insert into somecity.staff (forename, surname, office, email) Values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "')", con);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }

  2. #2

    Re: Windows Form Application C# - Confirmation Message on Add, Edit, Delete?

    if you are asking a really basic question, you can check with general samples as well.

    MessageBox.Show("new row added!"); would work fine after the con.close() you have. You can also check the number of records that has changed before\after based on the rowcount in your table and then display that to the user. In every case, it has to be done AFTER the add\edit\save\delete ops are done.

    --
    BossMode Software

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured