PC Review


Reply
Thread Tools Rate Thread

Binary field in SqlCE

 
 
Adam Goetz
Guest
Posts: n/a
 
      9th Sep 2003
I hope that I'm close with what I currently have :

trying save the data

command.CommandText = "UPDATE ConTable SET imagesignature = ? WHERE ConValue
= '" + sConValue + "';";
command.Parameters.Add("@imagesignature", SqlDbType.Image);
command.Parameters["@imagesignature"].Value = binSignature;
command.ExecuteNonQuery();

try to read the data back

sqlSelectTable.CommandText = "SELECT * from ConTable where ConValue = '" +
sConVlaue + "'";
SqlCeDataReader selectreader = sqlSelectTable.ExecuteReader();
if (selectreader.Read())
{
binSignature = selectreader.GetSqlBinary(ImageField);
};


My save appears to work - it doesn't exception and the SqlCe Query Analyser
shows that the field is non-null - though it doesn't show any data from the
field. Yes there is information in binSignature which is of type SqlBinary.
My load gives a binSignature.Length of 0 and an exception for
binSignature.Value.

Can anyone tell me what I've got wrong?


 
Reply With Quote
 
 
 
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      9th Sep 2003
When writing image data into DB use:

Dim sigData() as Byte
Dim param as SqlCeParameter = cmd.Parameters.Add("Signature",
SqlDbType.Image, sigData.Length);
param.Value = sigData;


Read like thi:
sigData = selectreader.GetSqlBinary(ImageField).Value;

"Adam Goetz" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I hope that I'm close with what I currently have :
>
> trying save the data
>
> command.CommandText = "UPDATE ConTable SET imagesignature = ? WHERE

ConValue
> = '" + sConValue + "';";
> command.Parameters.Add("@imagesignature", SqlDbType.Image);
> command.Parameters["@imagesignature"].Value = binSignature;
> command.ExecuteNonQuery();
>
> try to read the data back
>
> sqlSelectTable.CommandText = "SELECT * from ConTable where ConValue = '" +
> sConVlaue + "'";
> SqlCeDataReader selectreader = sqlSelectTable.ExecuteReader();
> if (selectreader.Read())
> {
> binSignature = selectreader.GetSqlBinary(ImageField);
> };
>
>
> My save appears to work - it doesn't exception and the SqlCe Query

Analyser
> shows that the field is non-null - though it doesn't show any data from

the
> field. Yes there is information in binSignature which is of type

SqlBinary.
> My load gives a binSignature.Length of 0 and an exception for
> binSignature.Value.
>
> Can anyone tell me what I've got wrong?
>
>



 
Reply With Quote
 
Adam Goetz
Guest
Posts: n/a
 
      9th Sep 2003
Thank you. I knew I was close.

"Alex Feinman [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> When writing image data into DB use:
>
> Dim sigData() as Byte
> Dim param as SqlCeParameter = cmd.Parameters.Add("Signature",
> SqlDbType.Image, sigData.Length);
> param.Value = sigData;
>
>
> Read like thi:
> sigData = selectreader.GetSqlBinary(ImageField).Value;
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading a binary field John Wright Microsoft VB .NET 1 7th Jul 2007 04:44 PM
Binary field won't take dates =?Utf-8?B?YWxlb24=?= Microsoft Access Queries 10 26th Jun 2007 11:06 PM
Set a binary field to NULL ? AlexT Microsoft Access ADP SQL Server 9 12th Dec 2005 05:56 AM
Re: binary field optimization Tim Ferguson Microsoft Access Database Table Design 1 10th Oct 2003 09:09 AM
SQLCE DataAdapter Update with Identity field PeterB Microsoft ADO .NET 5 9th Oct 2003 01:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:45 AM.