Monthly Archives: October 2011

SQL Compact data and schema script utility

When using a “normal” MsSql database (whatever the version), the management tool allow us to create a “database generation script”. This option does not exists for SqlCE Databases (soooo sad). Here is a little third-party tools that woes the trick… http://exportsqlce.codeplex.com/ Among creating “scripts”, the add-in adds the following menu items to the table context […]

[HowTo] Save Image into SqlCE database

Save into database. //Image to byte[] Image myImage = Image.FromFile(“c:\\xyz.jpg”); System.IO.MemoryStream imgMemoryStream = new System.IO.MemoryStream(); myImage.Save(imgMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] imgByteData = imgMemoryStream.GetBuffer(); //Store image bytes data into database SqlCeConnection scon = new SqlCeConnection(“Data Source=D:\\myDB.sdf”); SqlCeCommand cmd = new SqlCeCommand(“Update ImageTable Set Picture=@myPicture Where Username=’Martin'”, scon); cmd.Parameters.Add(“@myPicture”, SqlDbType.Image).Value = imgByteData; // Or cmd.Parameters.Add(“@myPicture”, SqlDbType.Binary).Value = imgByteData scon.Open(); […]