Mfwamba Tshimanga

Mfwamba Tshimanga

  • NA
  • 155
  • 43.9k

why its doesnt update?

Nov 6 2014 10:04 AM

Hi!
I receive this message "Not updated".
Please have a look if there is a wrong code somewhere. Because me I didnt see any wrong here:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;

 

namespace Entrada

{

    public partial class SaidaViatura : Form

    {

        OleDbConnection conn;

        OleDbCommand comm;

        string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\lunarentacar\lunarentacar\\app_data\office.mdb;Persist Security Info=False";

  public SaidaViatura()

        {

            InitializeComponent();

        }

        private void cbxCars(object sender, EventArgs e)

        {

            {

                conn = new OleDbConnection(connstr);

                comm = new OleDbCommand();

                conn.Open();

                OleDbParameter chaparia = new OleDbParameter("@chaparia", SqlDbType.VarChar);

                comm.Connection = conn;

                comm.CommandText = "UPDATE cars SET chaparia = @chaparia WHERE (code= @code)";

                try

                {

                    comm.ExecuteNonQuery();

                    //dgvSaidaviatura.CurrentCell.Value = dgvSaidaviatura.Rows[dgvSaidaviatura.Rows.Count - 1].Cells[0].Value;

                    MessageBox.Show("Update");

                }

                catch (Exception)

                {

                    MessageBox.Show("Not updated");

                }

                finally

                {

                    conn.Close();

                }

            }

 

 


Answers (6)