Modifier a partir d'une ligne

Résolu
thefolin - 9 nov. 2012 à 14:16
 thefolin - 14 nov. 2012 à 09:31
Bonjour Bonjour ,

Je vous écrit car je ne comprend pas mon erreur et je n'arrive pas a trouve une solution.
Bref voici le probleme .

Je code une application en c# WindFrom avec comme BDD Access .
Je rentre plusieurs données dans des champs . Je voudrais faire une mise a jour de c'est donné.

Biensur je connais la requete SQL UPDATE . Cette requete me pose quelle difficulté care je voudrais faire une mise a jour par rapport a la ligne .Je m"explique :
L'utlisateur va choisir la ligne qu'il veut faire une mise a jour et saisie dans des TextBox la mise a jour faire .

Je vous donne le bout de code . Petit précision je code en couche .

Couche de metier (ou il a y ma requete sql )
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Maquette.C.Metier
{
    class CL_TB_AP
    {
        public string rq_sql;

        public string m_AfficheALL(string UW)
        {
            this.rq_sql "SELECT DISTINCT Ligne,Unite_travail , Situation_travail , Localisation , Type FROM TB_GAZ WHERE Unite_travail'" + UW + "';";
            return this.rq_sql;
        }
        public string m_AfficheStart(string rows)
        {
            this.rq_sql = "SELECT DISTINCT Ligne,Unite_travail , Situation_travail , Localisation , Type FROM TB_GAZ";
            return this.rq_sql;
        }

        public string m_AjoutLocaType(string Loca, string Type, string Lignes)
        { 
            this.rq_sql "UPDATE TB_GAZ SET Localisation'"+ Loca+ "', Type= '" + Type+ "'WHERE Ligne = '" + Lignes + "';";
                return this.rq_sql;
        }


couche de metier aussi ou il y a la methode qui contient ma requete

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Maquette.C.Donnee;

namespace Maquette.C.Metier
{
    class CL_AP
    {
        private CL_CAD oCAD;
        private CL_TB_AP oAp;
        private System.Data.DataSet oDS;

        public CL_AP()
        {
            this.oCAD = new CL_CAD();
            this.oAp = new CL_TB_AP();
        }
        // affiche par Unite travail 
        public System.Data.DataSet m_affAP(string UW)
        {
            this.oDS = this.oCAD.m_getRows(this.oAp.m_AfficheALL(UW), UW);
            return this.oDS;
        }
        public System.Data.DataSet m_affStart(string UW)
        {
            this.oDS = this.oCAD.m_getRows(this.oAp.m_AfficheStart(UW), UW);
            return this.oDS;
        }


        // Ajout de TYPE ET DE LOCA 
        public void m_Ajout_Loca_Type(string Loca, string Type,string Lignes )
        {
            this.oCAD.m_ActionRows(this.oAp.m_AjoutLocaType(Loca, Type, Lignes));
        }
    }
}


Couche client (la windform)
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 Maquette.C.Metier;

namespace Maquette.C.Client
{
    public partial class Gaz_Analyse_Preliminaire : Form
    {
        public Gaz_Analyse_Preliminaire()
        {
            InitializeComponent();
        }
        private System.Data.DataSet oDS;

        private CL_AP oAp;

        private void Analyse_Preliminaire_Load(object sender, EventArgs e)
        {
            this.oDS = new DataSet();

            this.oAp = new CL_AP();

            //charger la dataGrieView 
            this.oDS = this.oAp.m_affStart("atex");
            this.dataGridView1.DataSource = this.oDS.Tables["atex"];
            this.dataGridView1.DataMember = "atex";

            // pour afficher le tableau  et re montrer encore le tableau 
            this.oDS = this.oAp.m_affStart(this.textBox1.Text);
            this.dataGridView1.DataSource = this.oDS;
            this.dataGridView1.DataMember = "atex";
        }

     
        private void button2_Click(object sender, EventArgs e)
        {      // Ajouter TYPE ET LOCA 
            this.oAp.m_Ajout_Loca_Type(this.textBox1.Text, this.comboBox4.Text,this.comboBox3.Text);
            // pour afficher le tableau 
            this.oDS = this.oAp.m_affAP(this.textBox1.Text);
            this.dataGridView1.DataSource = this.oDS;
            this.dataGridView1.DataMember = "atex";


            // pour afficher le tableau  et re montrer encore le tableau apres la sasie del'utilisateur
            this.oDS = this.oAp.m_affStart(this.textBox1.Text); // modifier textbox par une autre  si probleme 
            this.dataGridView1.DataSource = this.oDS;
            this.dataGridView1.DataMember = "atex";

        }


Le message d'erreur est : le type de donnée incompatible dans l'expression du critére
Dans ma BDD j'ai bien tous les champs en Texte.
J'utilise bien ma requete.
Hypothese
Je ne peux pas utilise de where dans ma reque UPDATE par rapport a ma ligne
La ligne est mon id dans ma BDD


Merci aux personnes qui ce pencherons sur ce probleme

1 réponse

C est bon l'erreur a etait modifier
La requete Sql a etait re fait
            this.rq_sql "UPDATE TB_GAZ SET Localisation'"+ Loca+ "', Type= '" + Type+ "' WHERE Ligne = " + Lignes + "";
                return this.rq_sql;
3
Rejoignez-nous