Bonjour,

Je veux créer une classe qui permet l'ajout dans la base de donné, jai fais comme suit:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
 
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Security.Principal;
 
namespace Projet1
{
    class connexion
    {
 
 
        public System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
        public System.Data.OleDb.OleDbConnection con;
 
        public void se(string conn)
        {
            WindowsIdentity i2 = WindowsIdentity.GetCurrent();
            string login = i2.Name;
 
            try
            {
                this.oleDbDataAdapter1.InsertCommand.CommandText =
                "INSERT INTO SECU (utilisateur)" +
                "VALUES( '" + login + "')";
                this.con.Open();
                this.oleDbDataAdapter1.InsertCommand.Connection = con;
                this.oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();
                this.con.Close();
            }
            catch (System.Data.OleDb.OleDbException exp)
            { this.con.Close(); }
       }
 
    }
 
}

mais quand je fais l'appel de nimport quel form on faisant connexion., la méthode se n'apparait pas, merci enormement.