using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class myprofile : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
string constr = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
string query = "SELECT tbl_user.email, myselfprofileClient.clientName, myselfprofileClient.clientImages, myselfprofileClient.CompanyDescription, myselfprofileClient.WebUrl, tbl_user.name,tbl_user.mobileNumber, tbl_user.password, tbl_user.repassword, tbl_user.professions, tbl_user.organisation, tbl_user.webUrl AS Expr1, tbl_user.activated, myselfprofileAddress.MobileNumber AS Expr2, myselfprofileAddress.UserAddress, myselfprofileaboutUs.aboutUs, myselfprofileheader.profile_pic, myselfprofileheader.headerimage, myselfprofileheader.facebookPageLink, myselfprofileheader.twitterPageLink, myselfprofileheader.googlePageLink, myselfprofileheader.linkedinPageLink, myselfprofileheader.headerSlidertext1, myselfprofileheader.headerSlidertext2, myselfprofileheader.headerSlidertext3, myselfprofileheader.headerSlidertext4, myselfprofileservices.servicesheader, myselfprofileservices.servicesone, myselfprofileservices.serviceoneDescription, myselfprofileservices.servicestwo, myselfprofileservices.servicetwoDescription, myselfprofileservices.servicesthree, myselfprofileservices.servicethreeDescription, myselfprofileservices.servicesfour, myselfprofileservices.servicefourDescription FROM tbl_user INNER JOIN myselfprofileaboutUs ON tbl_user.email = myselfprofileaboutUs.email INNER JOIN myselfprofileAddress ON tbl_user.mobileNumber = myselfprofileAddress.MobileNumber INNER JOIN myselfprofileClient ON tbl_user.email = myselfprofileClient.email INNER JOIN myselfprofileheader ON tbl_user.email = myselfprofileheader.email INNER JOIN myselfprofileservices ON tbl_user.email = myselfprofileservices.email where tbl_user.WebUrl="+this.Page.RouteData.Values["myprofile"].ToString();
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter sda = new SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
sda.SelectCommand = cmd;
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
//to set profile pic in main page
byte[] bytes = (byte[])dt.Rows[0]["profile_pic"];
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
Image1.ImageUrl = "data:image/png;base64," + base64String;
// to show footer image in main page
byte[] bytesfooter = (byte[])dt.Rows[0]["profile_pic"];
string base64Stringfooter = Convert.ToBase64String(bytesfooter, 0, bytesfooter.Length);
footerimg.ImageUrl = "data:image/png;base64," + base64Stringfooter;
//to show slider image in main page
byte[] bytesh = (byte[])dt.Rows[0]["headerimage"];
string base64Stringh = Convert.ToBase64String(bytesh, 0, bytesh.Length);
Image2.ImageUrl = "data:image/png;base64," + base64Stringh;
lblfblink.Text = dt.Rows[0]["facebookPageLink"].ToString();
lblTwitter.Text = dt.Rows[0]["twitterPageLink"].ToString();
lblGooglepluse.Text = dt.Rows[0]["googlePageLink"].ToString();
lbllinkedin.Text = dt.Rows[0]["linkedinPageLink"].ToString();
lbltextslider1.Text = dt.Rows[0]["headerSlidertext1"].ToString();
lbltextslider2.Text = dt.Rows[0]["headerSlidertext2"].ToString();
lbltextslider3.Text = dt.Rows[0]["headerSlidertext3"].ToString();
lbltextslider4.Text = dt.Rows[0]["headerSlidertext4"].ToString();
lblheader.Text = dt.Rows[0]["servicesheader"].ToString(); //Where ColumnName is the Field from the DB that you want to display
lblserviceone.Text = dt.Rows[0]["servicesone"].ToString();
lblserviceonedec.Text = dt.Rows[0]["serviceoneDescription"].ToString();
lblservicesecond.Text = dt.Rows[0]["servicestwo"].ToString();
lblserviceseconddec.Text = dt.Rows[0]["servicetwoDescription"].ToString();
lblservicethird.Text = dt.Rows[0]["servicesthree"].ToString();
lblservicethirddec.Text = dt.Rows[0]["servicethreeDescription"].ToString();
lblservicefourth.Text = dt.Rows[0]["servicesfour"].ToString();
lblservicefourthdec.Text = dt.Rows[0]["servicefourDescription"].ToString();
lblboutUs.Text = dt.Rows[0]["aboutUs"].ToString();
}
else
{
Response.Redirect("~/headerpage.aspx?=EmailId");
}
getDataAddress();
getClientData();
}
private void getClientData()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection(strConnString);
connection.Open();
SqlCommand sqlCmd = new SqlCommand("SELECT [myprifileclientId],[email],[clientName],[clientImages],[CompanyDescription],[WebUrl] FROM [db_myprofile].[dbo].[myselfprofileClient] WHERE email='" + Session["EmailId"] + "'", connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
//sqlCmd.Parameters.AddWithValue("@username", user);
//sqlDa.Fill(dt);
DataSet ds = new DataSet();
//sqlDa.Fill(ds);
sqlDa.Fill(ds);
//byte[] bytes = (byte[])dt.Rows[0]["clientImages"];
//string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
//string x = "data:image/png;base64," + base64String;
ClientDataList.DataSource = ds.Tables[0];
ClientDataList.DataBind();
//if (dt.Rows.Count > 0)
//{
// byte[] bytes = (byte[])dt.Rows[0]["clientImages"];
// string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
// ImageClient.ImageUrl = "data:image/png;base64," + base64String;
// //Where ColumnName is the Field from the DB that you want to display
// lblCompanyName.Text = dt.Rows[0]["clientName"].ToString();
// lblCompanyDescription.Text = dt.Rows[0]["CompanyDescription"].ToString();
// lblCompanyWebUrl.Text = dt.Rows[0]["WebUrl"].ToString();
//}
//connection.Close();
}
private void getDataAddress()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection(strConnString);
connection.Open();
SqlCommand sqlCmd = new SqlCommand("SELECT * FROM [db_myprofile].[dbo].[myselfprofileAddress] WHERE email='" + Session["EmailId"] + "'", connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
//sqlCmd.Parameters.AddWithValue("@username", user);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
lbladdress.Text = dt.Rows[0]["UserAddress"].ToString();
lblMobileNo.Text = dt.Rows[0]["MobileNumber"].ToString();
lblEmailAddress.Text = dt.Rows[0]["email"].ToString();
//Where ColumnName is the Field from the DB that you want to display
}
connection.Close();
}
}
this is my code please see this and help me.....