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
| Dim conn As OleDbConnection
Dim comand As New OleDbCommand
Dim cn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=MClient.accdb"
Dim dr As OleDb.OleDbDataReader
Dim sql As String
Sub saveClt(ByVal designation As String, ByVal email As String, ByVal tel As String)
Try
Dim res As Integer
conn = New OleDbConnection(cn)
sql = "INSERT INTO Client (denomination,Adresse_clt,telephone) VALUES (?,?,?)"
conn.Open()
comand.Connection = conn
comand.CommandType = CommandType.Text
comand.CommandText = sql
With comand
With .Parameters
.Add("designation", OleDbType.Char)
.Add("email", OleDbType.Char)
.Add("tel", OleDbType.Char)
End With
.Parameters("designation").Value = designation
.Parameters("email").Value = email
.Parameters("tel").Value = tel
End With
res = comand.ExecuteNonQuery
If res > 0 Then
MsgBox("Enregistré", MsgBoxStyle.Information, "Rapport")
'Return True
Else
MsgBox("Pas Enregistré", MsgBoxStyle.Exclamation, "Rapport")
'Return False
End If
conn.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Rapport")
End Try
End Sub |
Partager