Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4024344
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:42:37+00:00 2026-05-20T10:42:37+00:00

Alright, here we go! I am currently developing an iPhone app that will work

  • 0

Alright, here we go!

I am currently developing an iPhone app that will work as a security check-in system for events at a church. The main goal is to be able to search a pre existing MS SQL database for a participant, and then save them to a list on the iPhone/iPod Touch/iPad. Easy enough. One of the fields in the MS SQL database is of Image data type, and its function is to store the participant’s image in binary form. I currently am not allowed to switch to varbinary(MAX).

From the iPhone, I use:

UIImage *image = [UIImage imageNamed:@"nameOfImage.jpg"];  
NSData *imageData = UIImageJPEGRepresentation(image,1.0);  
NSString *imageString = (NSString *)[[[NSString alloc] init] base64StringFromData:(NSData *)imageData];

You may be wondering what the base64StringFromData is. It’s a category discussed here, How do I do base64 encoding on iphone-sdk?

In the category, it returns a string as NSASCIIStringEncoding. I then send that string to a Visual Basic web service using POST.

Assume in the following that I have already set up and opened my SQL connection, and initlialized a SQL Data adapter and command. So the function looks similar to this:

Public Function sendCommand(ByVal image As String) As String
   Dim commandString As String
   commandString = "insert into phoneApp(image) values(@image)"

   Dim encoding As New System.Text.UTF8Encoding

   sqlDataAdapter.InsertCommand = (commandString, sqlConnection)
   sqlDataAdapter.InsertCommand.Parameters.Add(@"image", SqlDbType.Image, image.length).Value = encoding.GetBytes(image)
   sqlDataAdapter.ExecuteNonQuery()
End Function

Now, finally, here’s what is happening. In another function, I call Response.BinaryWrite(SqlDataReader.Item(“image”)). In Internet Explorer, doing this would then make the image appear in the browser. Instead, it displays the string in base64 form. Copy and pasting that string in a base64 converter off the net, and it works. So the encoding on the iPhone did encode to base64 properly.

Here’s the question. Do I even need to be encoding to base64 to save into Image Data Type, or should I be focusing on learning how to encode the NSData into a different binary string?

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:42:37+00:00Added an answer on May 20, 2026 at 10:42 am

    I figured it out, and will leave my answer to anyone that stumbles across this. Good luck to you in your programming.

    It actually was a lot simpler than I thought. Just use System.Convert to pass in the bytes on the InsertCommand.

       sqlDataAdapter.InsertCommand = (commandString, sqlConnection)
       sqlDataAdapter.InsertCommand.Parameters.Add(@"image", SqlDbType.Image, image.length).Value = System.Convert.FromBase64String(image)
       sqlDataAdapter.ExecuteNonQuery()
    

    In essence, I was getting the bytes for the encoding string but never decoding it further down the line. So I stopped the double encoding by using the Convert before it was inserted into the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, here is the output I get: arm-none-linux-gnueabi-ld --entry=main -dynamic-linker=/system/bin/linker -rpath-link=/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -L/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib -nostdlib -lstdc++
Alright so here's my current code: import System.IO import System.Environment import System.Directory main =
Alright, I have a strange one here. We currently have a tools application that
Alright so here is my issue. I'm working a game engine that will eventually
Alright...I am here looking for some bread crumbs. This is my code: using System;
Alright, here goes. I'm making a very basic app, and I want the user
Alright, so I'm making a Facebook-style chat. But that doesn't really matter. See here:
Alright, so here's my problem. I'm trying to write a script in PHP that
Alright here's the situation, I have an application written in the Zend_Framework, that is
Alright, relevant information can be found in this thread(Is that what they're called here?).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.