I save the image data by converting it into byte array from base64 and image data is also inserted into database, now how to retrieve it back in base6

  • Thread starter Thread starter AnkitSoni29
  • Start date Start date
A

AnkitSoni29

Guest
What I did Yet :-

[WebMethod]
public void GetBusiness(Int64 ID)
{
List<Business> listEmployees = new List<Business>();
try
{


using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
SqlCommand sqlcom = new SqlCommand("[GetBusiness]", connection);
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Parameters.AddWithValue("@ID", ID);
connection.Open();
SqlDataReader rdr = sqlcom.ExecuteReader();
while (rdr.Read())
{
Business business = new Business();
business.ID = Convert.ToInt64(rdr["ID"]);
business.BusinessName = rdr["BusinessName"].ToString();
business.FirstName = rdr["FirstName"].ToString();
business.LastName = rdr["LastName"].ToString();
business.Address = rdr["Address"].ToString();
business.City = rdr["City"].ToString();
business.State = rdr["State"].ToString();
business.Country = rdr["Country"].ToString();
business.EmailID = rdr["EmailID"].ToString();
business.ContactNumber = rdr["ContactNumber"].ToString();
business.AppDownloaded = rdr["AppDownloaded"].ToString();
business.AppUpgrade = rdr["AppUpgrade"].ToString();
business.AppVersion = rdr["AppVersion"].ToString();
business.CreatedDate = rdr["CreatedDate"].ToString();
business.RowStatus = Convert.ToInt16(rdr["RowStatus"]);
business.UserName = rdr["UserName"].ToString();
business.AdminPassword = rdr["AdminPassword"].ToString();
business.IPAddress = rdr["IPAddress"].ToString();
business.BusinessLogo = Convert.ToBase64String(rdr["BusinessLogo"]);

listEmployees.Add(business);
}
}
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Write(js.Serialize(listEmployees));
}
catch (Exception ex)
{
JavaScriptSerializer a = new JavaScriptSerializer();
var varResult = new { result = "Error", Error = ex };
Context.Response.Write(a.Serialize(varResult));
}
}

Now i am Getting Error on :- business.BusinessLogo = Convert.ToBase64String(rdr["BusinessLogo"]);

Continue reading...
 
Back
Top