Click here to Skip to main content
15,914,444 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
protected void Button3_Click(object sender, EventArgs e)
   {
       str = "select [password] from logins where [user]='" + TextBox1.Text + "'";
       conn.Open();
       cmd.Connection = conn;
       cmd.CommandText = str;
       dr = cmd.ExecuteReader();
       if (dr.Read())
       {
           find = true;
       }
       conn.Close();

       if (find == true)
       {
           Label1.Text = Request.QueryString["password"].ToString();
          
           return;
       }

       Label1.Text = "You enter wrong username";

plz correct it ...
i want to output only password ..i have logins table where field are id ,username,password
Posted
Updated 11-Jul-14 20:41pm
v2
Comments
[no name] 11-Jul-14 8:58am    
There is nothing to "correct" here other than the obvious problem that your code snippet would not compile. "Topstring" is not a valid method call unless you created a method by that name. You probably want ToString(). You have not asked a question or described any kind of a problem.

Please try Label1.Text = Request.QueryString["password"].ToString();
 
Share this answer
 
It's very simple but we will not do all your work for you.

Just retrieve the value from the database that you want and then set the Label1.Text to that value.

Your current code, which has typos, is pulling from the QueryString.
 
Share this answer
 
Hi,

First fetch the value from database on C# page and set the value to Label1.Text.

If you have to send on another page then you can send through QueryString then write Label1.Text = Request.QueryString["ValueField"].ToString();

Check and Confirm. If you have any confusion then you can ask me.
 
Share this answer
 
Comments
chunty 12-Jul-14 2:50am    
protected void Button3_Click(object sender, EventArgs e)
{
str = "select [password] from logins where [user]='" + TextBox1.Text + "'";
conn.Open();
cmd.Connection = conn;
cmd.CommandText = str;
dr = cmd.ExecuteReader();
if (dr.Read())
{
find = true;
}
conn.Close();

if (find == true)
{
Label1.Text = Request.QueryString["password"].ToString();
//Response.Redirect("Default.aspx");
return;
}

Label1.Text = "You enter wrong username"; ican'access output plz giving a another solution

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