Click here to Skip to main content
15,889,693 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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;
                // ToSaveImageName = DateTime.Now.ToString("yyyy-MM-ddTmm:hh:ss");
                //ToSaveImageName.Replace('-', '1');
                //ToSaveImageName.Replace(':', '2');  
                //Directory.CreateDirectory(myMap + ToSaveImageName);
                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();
           }
       }
Posted
Updated 24-Mar-11 19:54pm
v2
Comments
R. Erasmus 25-Mar-11 3:38am    
Choosing a more specific subject line could get you answers on your questions alot faster.
Sandeep Mewara 25-Mar-11 5:08am    
Multiple reposts... I have lost the count now! :doh:

1 solution

Using debugger you can most likely find the cause or at least to better pinpoint the problem. Things to check would be something like:
- is ds.Tables[0].Rows[0].ItemArray[7] containing the correct information
- is the url correct constructed from "~/UserImage/" + ds.Tables[0].Rows[0].ItemArra[7].ToString();
- are actually executing the insides of the if statements
- etc. etc.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900