本文介绍了检查代码plz ........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了注册和登录"页面和用户详细信息"页面,但是图像未显示在用户详细信息"页面上

我的表格是用户
ID int
电子邮件主键varchar(250)
密码varchar(250)
名称varchar(250)
国家varchar(250)

说明varchar(50)
ImageName varchar(1000)

LoginPage代码为

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();
           }
       }

推荐答案


这篇关于检查代码plz ........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 13:30