Click here to Skip to main content
15,896,401 members

From the database fetch the value to another page using asp.net

Member 8054539 asked:

Open original thread
first i create database fields as follows Login Id,Firstnmae,Lastnmae and password

values as follows 1,ram,sam,123 etc table name entry.

First Design page as follows;

Username txt_username(textbox)
Password txt_password (textbox)

Insert (button) CLear(button)

when i type username and password values from the entry table such as login id 1 and password from the entry table and click the insert button it shows the message valid loginid and password.when i type wrong username and password it shows the message invalid loginid and password.


Second Design page as follows

Firstname txt_firstname(textbox)
Lastname txt_lastname(textbox)

when i click the insert buton from the first desing page it goes to second design page and output as

in that page i want the output as
Firstname ram
Lastname sam

From the entry table(database).

for the oupput how to write the code and in which page code has to be write please mention.it will be great useful for me.

First design page code as follows;
C#
protected void Button1_Click1(object sender, EventArgs e)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select LoginID,Password from entry where LoginID = '" + txt_username.Text + "' and Password = '" + txt_password.Text + "'", con);
       
      SqlDataReader  dr = cmd.ExecuteReader();

        if (dr.HasRows)
        {
            Session["LoginID"] = txt_username.Text;
            dr.Close();
            con.Close();
            Label3.Text = "Valid loginid and password";
            Label3.ForeColor = System.Drawing.Color.DarkRed;
            Server.Transfer("default2.aspx");
        }
        else
        {
            Label3.Text = "Invalid loginid and password";
            Label3.ForeColor = System.Drawing.Color.DarkGreen;
        }

    }

Please help me.
Tags: C#

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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