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
|
Dim err As Integer
Dim req As String
Dim myCommand As SqlCommand
req = "INSERT INTO CONTACT (NAME_CONTACT,LAST_NAME_CONTACT,JOB_TITLE_CONTACT,EMAIL_CONTACT,PHONE_NUMBER_CONTACT,FAX_CONTACT)"
req = req & " VALUES(Cast(@name as text),cast(@LastName as text),cast(@JobTitle as text),cast(@Email as text),cast(@Phone as text),cast(@Fax as text))"
'Ma fonction GetoConn est fonctionnelle, mes objets myCommand en lecture ne posaient pas de problème.
myCommand = New SqlCommand(req, GetoConn())
With myCommand.Parameters
.Add(New SqlParameter("@name", SqlDbType.Char, 50))
.Add(New SqlParameter("@LastName", SqlDbType.Char, 50))
.Add(New SqlParameter("@JobTitle", SqlDbType.Char, 50))
.Add(New SqlParameter("@Email", SqlDbType.Char, 50))
.Add(New SqlParameter("@Phone", SqlDbType.Char, 50))
.Add(New SqlParameter("@Fax", SqlDbType.Char, 50))
End With
With myCommand
.Parameters("@name").Value = CChar(name)
.Parameters("@LastName").Value = CChar(LastName)
.Parameters("@JobTitle").Value = CChar(JobTitle)
.Parameters("@Email").Value = CChar(Email)
.Parameters("@Phone").Value = CChar(Phone)
.Parameters("@Fax").Value = CChar(Fax)
Try
'Execution de la requête
Req_SQL.Connection.Open()
Req_SQL.ExecuteNonQuery()
Req_SQL.Connection.Close()
Catch ex As Exception
Return Err.Number
End Try |
Partager