How to Store image in SQLCE database for .NET2005 using C# smart device applications

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dipalipatel
    New Member
    • Nov 2008
    • 21

    #1

    How to Store image in SQLCE database for .NET2005 using C# smart device applications

    Hi,

    I have a very hard time to insert Image into Sqlce Database.

    Table : Test
    Column : mypic
    Datatype : image

    below the code while i am inserting

    signFile.txt is already captured image's conversion into txt file


    FileStream stream = new FileStream("\\S ignFile.txt", FileMode.Open, FileAccess.Read );
    BinaryReader reader = new BinaryReader(st ream);

    byte[] photo = reader.ReadByte s((int)stream.L ength);
    reader.Close();
    stream.Close();


    SqlCeCommand cmd = new SqlCeCommand("I NSERT INTO Test (mypic) " +
    " VALUES (@mypic)", conn);

    cmd.Parameters. Add("@mypic", SqlDbType.Image , photo.Length).V alue = photo;

    conn.Open();
    cmd.ExecuteNonQ uery();
    conn.Close();


    While i am doing it's giving an error that "There was an error parsing the query.[Toekn line no, Token line offset....] "

    Can any one help me with this???
    Thanks in advance.
Working...