bonjour,
je travaille sur une application, j'utilise vb.net et pour ma base sql server.
tout va bien jusqu'au moment ou je veux insérer dans la base à partir d'une classe autre que celle du formulaire.
je n'utilise pas un data adapter mais je configure ma connexion et ma requête à partir du code, voici le code si vous pourrez m'aider je serais très reconnaissante
qd il arrive à la l'instruction " mycommand.executeNonQuery" il déclenche une errur Système.
tout en sachant que la clé est un numéro séquentiel c'est pour celà que je ne l'ajoute pas ds les paramètres de la requête.

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
44
45
46
47
48
49
50
51
52
53
 
Public Sub AjouterExpert(ByVal cod As String, ByVal n As String, ByVal p As String, ByVal d As Date, ByVal prof As String, ByVal pos As String, ByVal posprop As String, ByVal emp As String, ByVal an As Integer, ByVal mail As String, ByVal f As Integer, ByVal t As Integer) 
Dim pa As String 
Dim marequete As String 
pa = cod.Substring(6, 2) 
codeExpert = cod 
nom = n 
prenom = p 
dateDeNaissance = d 
profession = prof 
employeurActuel = emp 
positionActuelle = pos 
positionProposee = posprop 
telephone = t 
e_mail = mail 
fax = f 
anneePositionActuelle = an 
Dim MyConnexion As SqlConnection = New SqlConnection("Data Source=MANEL;" & _ 
"Integrated Security=SSPI;Initial Catalog=METAP") 
marequete = "INSERT INTO Expert(CODEPAYS,CODEEXPERT,NOM,PRENOM,DATEDENAISSANCE,PROFESSION,POSITIONACTUELLE,EMPLOYEURACTUEL,ANNEEPOSITIONACTUELLE,TELEPHONE,E_MAIL,FAX,POSITIONPROPOSEE) values (@pa,@codeExpert,@nom,@prenom,@dn,@pr,@pos,@emp,@an,@tel,@email,@fax,@posp)" 
Dim mycommand As SqlCommand = New SqlCommand(marequete, MyConnexion) 
With mycommand.Parameters() 
.Add(New SqlParameter("@pa", SqlDbType.VarChar)) 
.Add(New SqlParameter("@codeExpert", SqlDbType.VarChar)) 
.Add(New SqlParameter("@nom", SqlDbType.VarChar)) 
.Add(New SqlParameter("@prenom", SqlDbType.VarChar)) 
.Add(New SqlParameter("@dn", SqlDbType.DateTime, 8)) 
.Add(New SqlParameter("@pr", SqlDbType.VarChar)) 
.Add(New SqlParameter("@pos", SqlDbType.VarChar)) 
.Add(New SqlParameter("@emp", SqlDbType.VarChar)) 
.Add(New SqlParameter("@an", SqlDbType.Int, 4)) 
.Add(New SqlParameter("@tel", SqlDbType.Int, 4)) 
.Add(New SqlParameter("@email", SqlDbType.VarChar)) 
.Add(New SqlParameter("@fax", SqlDbType.Int, 4)) 
.Add(New SqlParameter("@posp", SqlDbType.VarChar)) 
End With 
With mycommand 
.Parameters("@pa").Value = pa 
.Parameters("@codeExpert").Value = codeExpert 
.Parameters("@nom").Value = nom 
.Parameters("@prenom").Value = prenom 
.Parameters("@dn").Value = dateDeNaissance 
.Parameters("@pr").Value = profession 
.Parameters("@pos").Value = positionActuelle 
.Parameters("@emp").Value = employeurActuel 
.Parameters("@an").Value = anneePositionActuelle 
.Parameters("@tel").Value = telephone 
.Parameters("@fax").Value = fax 
.Parameters("@posp").Value = positionProposee 
End With 
mycommand.Connection.Open() 
mycommand.ExecuteNonQuery() 
End Sub
tu as raison DarkMolo, c'est une erreur qui s'est glissée, c mycommand.executeNonQuery qui déclenche cette erreur
l'erreur déclenchée est :
"Une exception non gérée du type 'System.Data.SqlClient.SqlException' s'est produite dans system.data.dll

Informations supplémentaires*: Erreur système."
merci pour vous tous