inkpicture base64 save to sql server image - InfoPath Dev
in

InfoPath Dev

inkpicture base64 save to sql server image

Last post 04-17-2010 03:53 AM by Hilary Stoupa. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 04-16-2010 08:38 AM

    inkpicture base64 save to sql server image

    I have a problem that is bothering me. I have embedded inkpicture controls on a form that is encoded to base64 in the xml. I am going to use a web service to submit the form to a sql server 2005 database. I need to save the base64 data to an image data type in sql server as an image so that a SSRS report can view the images. How do I do that? It seems that I will need to write code to decode the base64 data back to an image data and then save the record. I am using VB.

    Thanks

     

  • 04-16-2010 08:52 AM In reply to

    Re: inkpicture base64 save to sql server image

    We use our web service for submitting to SQL (DBXL) and I simply map the field in the form that has the base64 data to an nvarchar(max) column in my SQL table. SSRS handles base64 just fine -- you simply need to use an expression for the image source like:

    =System.Convert.FromBase64String(Fields!FieldName.Value)

    With, of course, the field your base64 data is in.

    So, if you are writing custom code to submit to SQL (though I encourage you to try our web services instead, as they are simpler and reusable) you can just save the content of the base64 field to your db and then use it in your report, easy-peasy.

    Hilary Stoupa

  • 04-16-2010 09:15 AM In reply to

    Re: inkpicture base64 save to sql server image

    OK. thanks. I was just looking into the SSRS side to see if they handle base64 data. This makes it much easier for me not to worry about it in infopath. Also, we were storing the data image data type. Maybe it is better to use nvarchar(max) instead to store the inkpictures. Thanks again.

     

  • 04-16-2010 01:12 PM In reply to

    Re: inkpicture base64 save to sql server image

    I have a new issue. I changed the data types in the sql database to varchar(max) from image data type. I use a schema from Visual Studio that maps the sql fields and create an xsd file. I use this file as the basis for the InfoPath form. When I changed the main data source in InfoPath, I get an error on the ink picture controls that says the control cannot store this data type. That is because it is now a simple type when it was before a base64binary. How did you get your sql mapping to work with varchar(max)?

    I see two options for now: I have to manually edit the xsd file that was created to change them back to base64binary or to somehow get the image or varbinary(max) fields in sql to work. I tried System.Convert.FromBase64String(Fields!FieldName.Value) in SSRS based on an image field but that does not work.

    thanks

     

  • 04-17-2010 03:53 AM In reply to

    Re: inkpicture base64 save to sql server image

    Convert.FromBase64String only works when you have base64 string data. So, if you want to test it, you can always convert an image to base64 (add a picture control to a form, attach an image, open the XML with notepad, copy the base64 in the image field and paste it into a db field, for example, then report on it).

    Like I said, we don't use database bound forms generally (but it sounds like your form isn't db bound? just that you are using VS to create the schema?) -- we use our web services to submit to SQL, which allows me to design forms with a field for an image file, then using our mapping tools, save the field value to an nvarchar(max) column. If you are going the custom code route, you could write some code the submitted your image fields as strings to your DB, just as they are in the form. As you mention, you could also try modifying the schema to base64Binary instead -- just create a template from scratch and look at the schema file after you've added a picture control for the syntax.

    Hilary Stoupa

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.