Salut,

Envoyé par
Er3van
L'erreur est tout à fait normale, tu essayes de concaténer des chaines de caractères avec un MemoryStream
strSql = "insert into dbo.entreprise values('" & TextBox1.Text & "','" & PictureBoxImageToBytes(PictureBox1) & "' ,'" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "')"
Ici, PictureBoxImageToBytes(PictureBox1) retourne un tableau de Byte, et non une chaîne de caractère..

Envoyé par
Er3van
Si tu veux la chaine associée à ton MemoryStream, tu peux passer par un StreamReader et la méthode ReadToEnd
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Public Function ReadAll(ByVal memStream As MemoryStream) As String
' Reset the stream otherwise you will just get an empty string.
' Remember the position so we can restore it later.
Dim pos = memStream.Position
memStream.Position = 0
Dim reader As New StreamReader(memStream)
Dim str = reader.ReadToEnd()
' Reset the position so that subsequent writes are correct.
memStream.Position = pos
Return str
End Function |
Partager