INSERIR DADOS BINARIOS COM PARAMETROS

DANLEONHART 07/01/2012 19:09:50
#392635
Seguinte...

Estou tentando salvar dados binários com o seguinte script:
 
Sub Gravar_Dados()
Dim Cmd As ADODB.Command
Dim Inserir As String

Inserir = [Ô]INSERT INTO InDat(Nome,Foto)VALUES(@Nome,@Foto)[Ô]
Abb
Set Cmd = New ADODB.Command
With Cmd
.ActiveConnection = Con
.Prepared = True
.CommandText = Inserir
.CommandType = adCmdText
.Parameters.Append .CreateParameter([Ô]@Nome[Ô], adBSTR, adParamInput, , txtNome.Text)
.Parameters.Append .CreateParameter([Ô]@Foto[Ô], adBinary, adParamInput, , Por_Em_Byte(camFoto))
.Execute
End With
MsgBox [Ô]Salvo ![Ô], vbInformation
Set Cmd = Nothing
Con.Close
End Sub


Está apresentando o seguinte erro:
[txt-color=#e80000]Erro: 3001
Os argumentos são incorretos, estão fora do intervalo aceitável ou estão em conflito.[/txt-color]


E aponta para a linha: [txt-color=#0000f0].Parameters.Append .CreateParameter([Ô]@Foto[Ô], adBinary, adParamInput, , Por_Em_Byte(camFoto))[/txt-color]

O script da função Por_Em_Byte é esse:

Function Por_Em_Byte(vArq As String) As Variant
Dim fileB As Long
Dim bts() As Byte
fileNum = FreeFile
fileB = FreeFile

Open vArq For Binary Access Read As #fileNum
ReDim bts(1 To LOF(fileNum))
Get fileNum, , bts()
Close fileNum

Por_Em_Byte = bts()

End Function
KERPLUNK 09/01/2012 09:26:20
#392707
Tente assim:

Inserir = [Ô]INSERT INTO InDat(Nome,Foto)VALUES(?,?)[Ô]
Abb
Set Cmd = New ADODB.Command
With Cmd
.ActiveConnection = Con
.Prepared = True
.CommandText = Inserir
.CommandType = adCmdText
.Parameters.Append .CreateParameter([Ô]?Nome[Ô], adBSTR, adParamInput, , txtNome.Text)
.Parameters.Append .CreateParameter([Ô]?Foto[Ô], adBinary, adParamInput, , Por_Em_Byte(camFoto))
.Execute
End With
MsgBox [Ô]Salvo ![Ô], vbInformation
Set Cmd = Nothing
Tópico encerrado , respostas não são mais permitidas