I develop Register and Login page and UserDetails page but image is not display on UserDetails page
MY tabel is User
ID int
Email primarykey varchar(250)
Password varchar(250)
Name varchar(250)
Country varchar(250)
Description varchar(50)
ImageName varchar(1000)
LoginPage code is
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\omar\Documents\Visual Studio 2005\WebSites\WebSite8\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
con.Open();
string mycmd="Select * from [User]where Email='"+TextBox1.Text+"'AND Password='"+TextBox2.Text+"'";
SqlDataAdapter da=new SqlDataAdapter(mycmd,con);
DataSet ds = new DataSet();
da.Fill(ds,"MyDataSet");
int RowCount=ds.Tables[0].Rows.Count;
if(RowCount==0)
{
Response.Write("<script language='javascript'>alert( 'Invalid password or Email ' )</script>");
}
else{
Session["ID"]=ds.Tables[0].Rows[0].ItemArray[0];
Response.Redirect("UserDetails.aspx");
Register Page code is
SqlConnection con1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\omar\Documents\Visual Studio 2005\WebSites\WebSite8\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
con1.Open();
SqlCommand sc = new SqlCommand("Select Email from [User]", con1);
SqlDataReader rd;
rd = sc.ExecuteReader();
while (rd.Read())
{
if (rd["Email"].ToString().Equals(TextBox1.Text))
{
Response.Write("<script language='javascript'>alert( 'Already Exsist ' )</script>");
k = 1;
}
}
con1.Close();
if (k == 0)
{
if (UploadUserPhoto.PostedFile != null)
{
string myMap = MapPath("~/").ToLower();
Random r = new Random();
int next = r.Next();
string ImageName = UploadUserPhoto.PostedFile.FileName;
sImageFileExtension = ImageName.Substring(ImageName.LastIndexOf(".")).ToLower();
if (sImageFileExtension == ".gif" || sImageFileExtension == ".png" || sImageFileExtension == ".jpg" || sImageFileExtension == ".jpeg" || sImageFileExtension == ".bmp")
{
string ImageSaveURL = myMap + "UserImage/" + next + sImageFileExtension;
UploadUserPhoto.PostedFile.SaveAs(ImageSaveURL);
string RegisterQuery = "INSERT INTO [User](Email,Password,Name,Country,Gender,Month,Date,Year,Description,ImageName) VALUES('"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox4.Text+"','"+TextBox5.Text+"','"+DropDownList1.Text+"','"+DropDownList2.Text+"','"+DropDownList3.Text+"','"+DropDownList4.Text+"','"+TextBox6.Text+"','" + next + sImageFileExtension + "')";
dbClass.ConnectDataBaseToInsert(RegisterQuery);
Response.Redirect("~/Lo.aspx");
}
}
}
User Details page code is in below code where i am wrong in below codei also give loginpage and register page code above so tell me acording that
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString.HasKeys())
{
string ID;
ID= Request.QueryString["ID"];
if(!string.IsNullOrEmpty(ID))
{
SqlConnection con=new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\omar\Documents\Visual Studio 2005\WebSites\WebSite8\App_Data\Database.mdf;Integrated Security=True;User Instance=True");
string sql = "Select * From [User] Where ID=" + Session["ID"].ToString();
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataSet ds = new DataSet();
da.Fill(ds);
Image1.ImageUrl = "~/UserImage/" + ds.Tables[0].Rows[0].ItemArra[7].ToString();
}
}