Bonjour,

Je viens de commencer une application VB.net en multi-couche pour l'instant je m'en sortait pas trop mal mais là pour l'insertion d'un USERS je bloque un peu.

voici ma classe USERS

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
40
41
42
43
 
Imports System.Data
Imports System.Data.OleDb
 
Public Class utilisateur
 
    Inherits DAO.connexion
 
    Private sql As String = "select * from USERS"
    Private AdaptUsers As OleDb.OleDbDataAdapter()
    Private DtsetUsers As New DataSet()
 
    Public Sub Create_table()
        Dim sql As String
        sql = "CREATE TABLE USERS (LOGIN CHAR(10) NOT NULL PRIMARY KEY,MDP CHAR(10) NOT NULL,QUESTION VARCHAR(32) NOT NULL,REPONSE CHAR(10) NOT NULL)"
        Creation_table(sql)
    End Sub
 
    Private Sub Table_Users()
        Open_connect()
        Dim AdaptUsers As New OleDb.OleDbDataAdapter(sql, get_cnxstr)
        AdaptUsers.Fill(DtsetUsers, "USERS")
        Close_connect()
    End Sub
 
    Public Sub create_users(ByVal login As String, ByVal mdp As String, ByVal question As String, ByVal rep As String)
        Table_Users()
        Dim newLigne As DataRow
        Dim CmdBuild As OleDb.OleDbCommandBuilder
        newLigne = DtsetUsers.Tables("USERS").NewRow
        newLigne(0) = login
        newLigne(1) = mdp
        newLigne(2) = question
        newLigne(3) = rep
        DtsetUsers.Tables("USERS").Rows.Add(newLigne)
        Open_connect()
        'N'accepte pas AdaptUsers
        CmdBuild = New OleDb.OleDbCommandBuilder(AdaptUsers)
        AdaptUsers.InsertCommand = CmdBuild.GetInsertCommand()
        AdaptUsers.Update(DtsetUsers, "USERS")
        Close_connect()
    End Sub
End Class
Mais sa bloque au niveau du passage du paramètre du oledbCommandBuiler(), il ne veut pas mon adaptUsers.

Merci pour votre aide