Byte Array - insert or update to database

P

PK

Hi,

How can I insert or update ByteArray data to the database ?

I get the signature value, but that value is in Byte Array type. I just
wonder how can I save that byte array to database. and how to load the
byte array to show the signature again.

I am using the Signature from Opennetcf.org....

hope someone could guide me how to insert the byte array to database.
and retireve it back later on

thank you very much
 
P

PK

Hi Alex, I have modify some code to become like this, but I am getting
Token Line Error.....could you please guide me what is the problem ?


Dim signbyte As Byte()
signbyte = GetByteArray() ' i create this function to return
ByteArray

Try
Dim cmd As New SqlCeCommand
cmd.Connection = myConnection

' you gave me the following insert statement....this ?
parameter is working,
'but I modify to update statement with @ or ?, both not
working....
'cmd.CommandText = "insert into test (picture) values (?)"

cmd.CommandText = "UPDATE bm00ts0001 SET imgarray =
@imgarray WHERE tid
= '" & vartid & "'"

Dim param As SqlCeParameter =
cmd.Parameters.Add("@imgarray",
SqlDbType.Image)
param.Value = signbyte

myConnection.Open()
cmd.ExecuteNonQuery()
myConnection.Close()

Catch sqex As SqlCeException
MessageBox.Show(sqex.ToString(), "DB operation failed")
Catch er As Exception
MessageBox.Show(er.ToString)
End Try
 
A

Alex Feinman [MVP]

With SQL CE you need to use ? as parameter value placeholders.

cmd.CommandText = "insert into test (picture) values ?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top