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 = "http://tempuri.org/")] [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 //InitializeComponent(); } [WebMethod] public string Hello(String ProName, String ProImage) { String message = " "; try { 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 hh.Save(strFileName); con = new SqlConnection(t3); con.Open(); cmd = new SqlCommand("insert into productDetails2 (ProductName,ImagePath) values (@ProductName,@Images)", con); cmd.Parameters.AddWithValue("@Productname", ProName); cmd.Parameters.AddWithValue("@Images", strFileName); cmd.ExecuteNonQuery(); con.Close(); message = "Addedd Successfullyy String \n " + strFileName; } catch (Exception ex) { message = ex.Message.ToString(); } return message; } }
Pingback: Connect Android to MS SQL Database. • ParallelCodes();
after refeering to these tutorial can i know how can i get back in android in imageview using we services