Android storing Images in MS SQL Server using ASP.NET Webservice by specifying Image Path.

Everything remains same as in my previous post on Android Storing Images in Base64 string in MS SQL server using Web Service.Only the webservices changes :

using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Configuration;
using System.Drawing;

/// <summary>
/// Summary description for ImagePath
/// </summary>
[WebService(Namespace = "")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class ImagePath : System.Web.Services.WebService

    SqlConnection con;
    String t3 = ConfigurationManager.ConnectionStrings["T3"].ConnectionString;
    SqlCommand cmd;
    SqlDataReader reader;
    String lastid;

    public ImagePath()

        //Uncomment the following line if using designed components 


    public string Hello(String ProName, String ProImage)
        String message = " ";
            byte[] bytes = Convert.FromBase64String(ProImage);
            System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bytes);
            Bitmap bitImage = new Bitmap((Bitmap)System.Drawing.Image.FromStream(streamBitmap));
            System.Drawing.Image hh = System.Drawing.Image.FromStream(streamBitmap);
            String strFileName = "E:\\UploadFile\\NewImage.jpg";// my E drive folder UploadFile
            con = new SqlConnection(t3);
            cmd = new SqlCommand("insert into productDetails2 (ProductName,ImagePath) values (@ProductName,@Images)", con);
            cmd.Parameters.AddWithValue("@Productname", ProName);
            cmd.Parameters.AddWithValue("@Images", strFileName);
            message = "Addedd Successfullyy String \n " + strFileName;
        catch (Exception ex)
            message = ex.Message.ToString();

return message;


One thought to “Android storing Images in MS SQL Server using ASP.NET Webservice by specifying Image Path.”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.