Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM ODBC Driver » View Thread |
Messages 11 to 15 of 15 total |
Inserting image into MEMO column |
Wed, Apr 29 2015 8:02 AM | Permanent Link |
Chris Holland SEC Solutions Ltd. Team Elevate | Hi Durendal,
I have posted a small test project for you into the Binaries newsgroup. (Created with Visual Studio 2013) I have modified your table slightly so that you can see the difference between using a MEMO and a GRAPHIC field type in the table. You can see that the GRAPHIC Type displays in the grid very easily. Hope this helps. Chris Holland [Team Elevate] On 29/04/2015 01:29, Durendal wrote: > Hi Chris, > > It is of type MEMO, please see the image and the table in the attached zip file. Thank you. > > > Chris Holland wrote: > > Hi Durendal, > > What is the Data Type for your "Document" column in the table? > > Chris Holland > [Team Elevate] > > On 28/04/2015 08:40, Durendal wrote: >> Hi Chris, >> >> In one of the older post (http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_odbc&msg=1794&page=3) you recommend OdbcType.Text for MEMO column. Would OdbcType.Image work as well? From the error msg, the driver seems to be expected something at the end of the byte[] being passed in. Thank you. >> >> >> Durendal wrote: >> >> Hi Chris, >> >> Is there any code needed for the memo column Document below? Without the Memo column, I am able to add the row. With the memo column (last column named Document), I got this error message >> >> "ERROR [42000] [Elevate Software][DBISAM] DBISAM Engine Error # 11949 SQL parsing error - Expected NULL, Memo expression but instead found ? in INSERT SQL statement at line 1, column 57" >> >> MyCommand.CommandText = "INSERT INTO dcdocument2 (ID, Name, Document) VALUES(?,?,?)"; >> >> MyCommand.Parameters.AddWithValue("ID", 3); >> MyCommand.Parameters.AddWithValue("Name", "Test3"); >> MyCommand.Parameters.Add("Document", OdbcType.Image); >> MyCommand.Parameters["Document"].Value = imagebytes; >> >> MyCommand.ExecuteNonQuery(); >> >> >> Chris Holland wrote: >> >> Something like this should do it: >> >> private byte[] imagebytes; >> public Image Portrait; >> >> using (OdbcCommand MyCommand = new OdbcCommand("", Info.Connection)) >> { >> MyCommand.CommandText = "INSERT INTO TableName" (ImageFld) VALUES(?)" >> >> Portrait = new Bitmap("C:\My Images\image001.jpg"); >> >> using (MemoryStream ms = new MemoryStream()) >> { >> Portrait.Save(ms, Portrait.RawFormat); >> imagebytes = ms.ToArray(); >> } >> >> MyCommand.Parameters.Add("ImageFld", OdbcType.Image); >> MyCommand.Parameters["ImageFld"].Value = imagebytes; >> >> MyCommand.ExecuteNonQuery(); >> } >> >> Chris Holland >> [Team Elevate] >> >> On 25/04/2015 01:48, Durendal wrote: >>> Hello, >>> >>> Using C#, how do I insert an image from a windows folder (i.e. C:\My Images\image001.jpg) into a table? Thank you. >>> >> > |
Wed, Apr 29 2015 11:36 AM | Permanent Link |
Durendal | Thank you, Chris. Because this is an existing DB, I don't have the flexibility to change the data type. I will download and try your sample. Thanks again.
Chris Holland wrote: Hi Durendal, I have posted a small test project for you into the Binaries newsgroup. (Created with Visual Studio 2013) I have modified your table slightly so that you can see the difference between using a MEMO and a GRAPHIC field type in the table. You can see that the GRAPHIC Type displays in the grid very easily. Hope this helps. Chris Holland [Team Elevate] On 29/04/2015 01:29, Durendal wrote: > Hi Chris, > > It is of type MEMO, please see the image and the table in the attached zip file. Thank you. > > > Chris Holland wrote: > > Hi Durendal, > > What is the Data Type for your "Document" column in the table? > > Chris Holland > [Team Elevate] > > On 28/04/2015 08:40, Durendal wrote: >> Hi Chris, >> >> In one of the older post (http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_odbc&msg=1794&page=3) you recommend OdbcType.Text for MEMO column. Would OdbcType.Image work as well? From the error msg, the driver seems to be expected something at the end of the byte[] being passed in. Thank you. >> >> >> Durendal wrote: >> >> Hi Chris, >> >> Is there any code needed for the memo column Document below? Without the Memo column, I am able to add the row. With the memo column (last column named Document), I got this error message >> >> "ERROR [42000] [Elevate Software][DBISAM] DBISAM Engine Error # 11949 SQL parsing error - Expected NULL, Memo expression but instead found ? in INSERT SQL statement at line 1, column 57" >> >> MyCommand.CommandText = "INSERT INTO dcdocument2 (ID, Name, Document) VALUES(?,?,?)"; >> >> MyCommand.Parameters.AddWithValue("ID", 3); >> MyCommand.Parameters.AddWithValue("Name", "Test3"); >> MyCommand.Parameters.Add("Document", OdbcType.Image); >> MyCommand.Parameters["Document"].Value = imagebytes; >> >> MyCommand.ExecuteNonQuery(); >> >> >> Chris Holland wrote: >> >> Something like this should do it: >> >> private byte[] imagebytes; >> public Image Portrait; >> >> using (OdbcCommand MyCommand = new OdbcCommand("", Info.Connection)) >> { >> MyCommand.CommandText = "INSERT INTO TableName" (ImageFld) VALUES(?)" >> >> Portrait = new Bitmap("C:\My Images\image001.jpg"); >> >> using (MemoryStream ms = new MemoryStream()) >> { >> Portrait.Save(ms, Portrait.RawFormat); >> imagebytes = ms.ToArray(); >> } >> >> MyCommand.Parameters.Add("ImageFld", OdbcType.Image); >> MyCommand.Parameters["ImageFld"].Value = imagebytes; >> >> MyCommand.ExecuteNonQuery(); >> } >> >> Chris Holland >> [Team Elevate] >> >> On 25/04/2015 01:48, Durendal wrote: >>> Hello, >>> >>> Using C#, how do I insert an image from a windows folder (i.e. C:\My Images\image001.jpg) into a table? Thank you. >>> >> > |
Wed, Apr 29 2015 11:43 AM | Permanent Link |
Durendal | Hi Chris,
Please help point me to your sample. I tried the http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_binaries newsgroup but the last post was in 2014. Chris Holland wrote: Hi Durendal, I have posted a small test project for you into the Binaries newsgroup. (Created with Visual Studio 2013) I have modified your table slightly so that you can see the difference between using a MEMO and a GRAPHIC field type in the table. You can see that the GRAPHIC Type displays in the grid very easily. Hope this helps. Chris Holland [Team Elevate] On 29/04/2015 01:29, Durendal wrote: > Hi Chris, > > It is of type MEMO, please see the image and the table in the attached zip file. Thank you. > > > Chris Holland wrote: > > Hi Durendal, > > What is the Data Type for your "Document" column in the table? > > Chris Holland > [Team Elevate] > > On 28/04/2015 08:40, Durendal wrote: >> Hi Chris, >> >> In one of the older post (http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_odbc&msg=1794&page=3) you recommend OdbcType.Text for MEMO column. Would OdbcType.Image work as well? From the error msg, the driver seems to be expected something at the end of the byte[] being passed in. Thank you. >> >> >> Durendal wrote: >> >> Hi Chris, >> >> Is there any code needed for the memo column Document below? Without the Memo column, I am able to add the row. With the memo column (last column named Document), I got this error message >> >> "ERROR [42000] [Elevate Software][DBISAM] DBISAM Engine Error # 11949 SQL parsing error - Expected NULL, Memo expression but instead found ? in INSERT SQL statement at line 1, column 57" >> >> MyCommand.CommandText = "INSERT INTO dcdocument2 (ID, Name, Document) VALUES(?,?,?)"; >> >> MyCommand.Parameters.AddWithValue("ID", 3); >> MyCommand.Parameters.AddWithValue("Name", "Test3"); >> MyCommand.Parameters.Add("Document", OdbcType.Image); >> MyCommand.Parameters["Document"].Value = imagebytes; >> >> MyCommand.ExecuteNonQuery(); >> >> >> Chris Holland wrote: >> >> Something like this should do it: >> >> private byte[] imagebytes; >> public Image Portrait; >> >> using (OdbcCommand MyCommand = new OdbcCommand("", Info.Connection)) >> { >> MyCommand.CommandText = "INSERT INTO TableName" (ImageFld) VALUES(?)" >> >> Portrait = new Bitmap("C:\My Images\image001.jpg"); >> >> using (MemoryStream ms = new MemoryStream()) >> { >> Portrait.Save(ms, Portrait.RawFormat); >> imagebytes = ms.ToArray(); >> } >> >> MyCommand.Parameters.Add("ImageFld", OdbcType.Image); >> MyCommand.Parameters["ImageFld"].Value = imagebytes; >> >> MyCommand.ExecuteNonQuery(); >> } >> >> Chris Holland >> [Team Elevate] >> >> On 25/04/2015 01:48, Durendal wrote: >>> Hello, >>> >>> Using C#, how do I insert an image from a windows folder (i.e. C:\My Images\image001.jpg) into a table? Thank you. >>> >> > |
Wed, Apr 29 2015 3:47 PM | Permanent Link |
Chris Holland SEC Solutions Ltd. Team Elevate | Durendal <> Wrote in message:
Hi Durendal, My mistake sorry, I posted it into the Web Builder binaries by mistake. Can you download it from there or else I can repost it to the correct place tomorrow afternoon as I am out of the office until then. > Hi Chris, > > Please help point me to your sample. I tried the http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_binaries newsgroup but the last post was in 2014. > > > Chris Holland wrote: > > Hi Durendal, > > I have posted a small test project for you into the Binaries newsgroup. > (Created with Visual Studio 2013) > > I have modified your table slightly so that you can see the difference > between using a MEMO and a GRAPHIC field type in the table. > > You can see that the GRAPHIC Type displays in the grid very easily. > > Hope this helps. > > Chris Holland > [Team Elevate] > > On 29/04/2015 01:29, Durendal wrote: >> Hi Chris, >> >> It is of type MEMO, please see the image and the table in the attached zip file. Thank you. >> >> >> Chris Holland wrote: >> >> Hi Durendal, >> >> What is the Data Type for your "Document" column in the table? >> >> Chris Holland >> [Team Elevate] >> >> On 28/04/2015 08:40, Durendal wrote: >>> Hi Chris, >>> >>> In one of the older post (http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_odbc&msg=1794&page=3) you recommend OdbcType.Text for MEMO column. Would OdbcType.Image work as well? From the error msg, the driver seems to be expected something at the end of the byte[] being passed in. Thank you. >>> >>> >>> Durendal wrote: >>> >>> Hi Chris, >>> >>> Is there any code needed for the memo column Document below? Without the Memo column, I am able to add the row. With the memo column (last column named Document), I got this error message >>> >>> "ERROR [42000] [Elevate Software][DBISAM] DBISAM Engine Error # 11949 SQL parsing error - Expected NULL, Memo expression but instead found ? in INSERT SQL statement at line 1, column 57" >>> >>> MyCommand.CommandText = "INSERT INTO dcdocument2 (ID, Name, Document) VALUES(?,?,?)"; >>> >>> MyCommand.Parameters.AddWithValue("ID", 3); >>> MyCommand.Parameters.AddWithValue("Name", "Test3"); >>> MyCommand.Parameters.Add("Document", OdbcType.Image); >>> MyCommand.Parameters["Document"].Value = imagebytes; >>> >>> MyCommand.ExecuteNonQuery(); >>> >>> >>> Chris Holland wrote: >>> >>> Something like this should do it: >>> >>> private byte[] imagebytes; >>> public Image Portrait; >>> >>> using (OdbcCommand MyCommand = new OdbcCommand("", Info.Connection)) >>> { >>> MyCommand.CommandText = "INSERT INTO TableName" (ImageFld) VALUES(?)" >>> >>> Portrait = new Bitmap("C:\My Images\image001.jpg"); >>> >>> using (MemoryStream ms = new MemoryStream()) >>> { >>> Portrait.Save(ms, Portrait.RawFormat); >>> imagebytes = ms.ToArray(); >>> } >>> >>> MyCommand.Parameters.Add("ImageFld", OdbcType.Image); >>> MyCommand.Parameters["ImageFld"].Value = imagebytes; >>> >>> MyCommand.ExecuteNonQuery(); >>> } >>> >>> Chris Holland >>> [Team Elevate] >>> >>> On 25/04/2015 01:48, Durendal wrote: >>>> Hello, >>>> >>>> Using C#, how do I insert an image from a windows folder (i.e. C:\My Images\image001.jpg) into a table? Thank you. >>>> >>> >> > > -- Chris Holland ----Android NewsGroup Reader---- http://usenet.sinaapp.com/ |
Wed, Apr 29 2015 3:57 PM | Permanent Link |
Chris Holland SEC Solutions Ltd. Team Elevate | Okay, I have managed to borrow a laptop and repost the example to the
correct newsgroup now. Sorry about the mix up. Chris Holland [Team Elevate] On 29/04/2015 16:43, Durendal wrote: > Hi Chris, > > Please help point me to your sample. I tried the http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_binaries newsgroup but the last post was in 2014. > > > Chris Holland wrote: > > Hi Durendal, > > I have posted a small test project for you into the Binaries newsgroup. > (Created with Visual Studio 2013) > > I have modified your table slightly so that you can see the difference > between using a MEMO and a GRAPHIC field type in the table. > > You can see that the GRAPHIC Type displays in the grid very easily. > > Hope this helps. > > Chris Holland > [Team Elevate] > > On 29/04/2015 01:29, Durendal wrote: >> Hi Chris, >> >> It is of type MEMO, please see the image and the table in the attached zip file. Thank you. >> >> >> Chris Holland wrote: >> >> Hi Durendal, >> >> What is the Data Type for your "Document" column in the table? >> >> Chris Holland >> [Team Elevate] >> >> On 28/04/2015 08:40, Durendal wrote: >>> Hi Chris, >>> >>> In one of the older post (http://www.elevatesoft.com/forums?action=view&category=dbisam&id=dbisam_odbc&msg=1794&page=3) you recommend OdbcType.Text for MEMO column. Would OdbcType.Image work as well? From the error msg, the driver seems to be expected something at the end of the byte[] being passed in. Thank you. >>> >>> >>> Durendal wrote: >>> >>> Hi Chris, >>> >>> Is there any code needed for the memo column Document below? Without the Memo column, I am able to add the row. With the memo column (last column named Document), I got this error message >>> >>> "ERROR [42000] [Elevate Software][DBISAM] DBISAM Engine Error # 11949 SQL parsing error - Expected NULL, Memo expression but instead found ? in INSERT SQL statement at line 1, column 57" >>> >>> MyCommand.CommandText = "INSERT INTO dcdocument2 (ID, Name, Document) VALUES(?,?,?)"; >>> >>> MyCommand.Parameters.AddWithValue("ID", 3); >>> MyCommand.Parameters.AddWithValue("Name", "Test3"); >>> MyCommand.Parameters.Add("Document", OdbcType.Image); >>> MyCommand.Parameters["Document"].Value = imagebytes; >>> >>> MyCommand.ExecuteNonQuery(); >>> >>> >>> Chris Holland wrote: >>> >>> Something like this should do it: >>> >>> private byte[] imagebytes; >>> public Image Portrait; >>> >>> using (OdbcCommand MyCommand = new OdbcCommand("", Info.Connection)) >>> { >>> MyCommand.CommandText = "INSERT INTO TableName" (ImageFld) VALUES(?)" >>> >>> Portrait = new Bitmap("C:\My Images\image001.jpg"); >>> >>> using (MemoryStream ms = new MemoryStream()) >>> { >>> Portrait.Save(ms, Portrait.RawFormat); >>> imagebytes = ms.ToArray(); >>> } >>> >>> MyCommand.Parameters.Add("ImageFld", OdbcType.Image); >>> MyCommand.Parameters["ImageFld"].Value = imagebytes; >>> >>> MyCommand.ExecuteNonQuery(); >>> } >>> >>> Chris Holland >>> [Team Elevate] >>> >>> On 25/04/2015 01:48, Durendal wrote: >>>> Hello, >>>> >>>> Using C#, how do I insert an image from a windows folder (i.e. C:\My Images\image001.jpg) into a table? Thank you. >>>> >>> >> > |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Wednesday, April 24, 2024 at 11:07 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |