Accessing data on a SQL-server

Discussion in 'ASP .Net' started by =?iso-8859-1?Q?S=F8ren_Jensen?=, Jul 4, 2003.

  1. I want to make an Aspx-page, where a user can enter a
    username and a loginname.

    I have create all parts execpt for the databaseconnection.

    what I want to do is:

    1) Create SQL-statement (like: Select * from userTBL
    where username=input and password=input)
    2) Open the connection and test if there is a record.
    3) If so, the user can login to the system.

    Can someone show me the simple sourcecode, since I am
    beginning to be tired of not being able to solve this
    problem.

    Best regards and greetings from Denmark.

    Søren
    =?iso-8859-1?Q?S=F8ren_Jensen?=, Jul 4, 2003
    #1
    1. Advertising

  2. =?iso-8859-1?Q?S=F8ren_Jensen?=

    dave wanta Guest

    you mean like this?
    (off the top of my head )
    string connectionString = "{my db connection string here}";
    string sqlText = "Select count(*) from userTBL where username=input and
    password=input";
    SqlCommand cmd = new SqlCommand( sqlText, new SqlConnection(
    sqlConnection ) );
    cmd.Connection.Open();

    int records = int.Parse( cmd.ExecuteScalar().ToString() );
    cmd.Connection.Close();


    if( records > 0 ){
    //user exists
    }
    else{
    //no user exists
    }

    hth,
    Dave
    www.aspNetEmail.com




    "Søren Jensen" <> wrote in message
    news:015101c34267$86707ed0$...
    I want to make an Aspx-page, where a user can enter a
    username and a loginname.

    I have create all parts execpt for the databaseconnection.

    what I want to do is:

    1) Create SQL-statement (like: Select * from userTBL
    where username=input and password=input)
    2) Open the connection and test if there is a record.
    3) If so, the user can login to the system.

    Can someone show me the simple sourcecode, since I am
    beginning to be tired of not being able to solve this
    problem.

    Best regards and greetings from Denmark.

    Søren
    dave wanta, Jul 5, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmV6YQ==?=
    Replies:
    3
    Views:
    17,885
    Carlos Barini
    Jun 7, 2004
  2. =?Utf-8?B?RGF2aWRS?=

    Accessing data from remote SQL Server.

    =?Utf-8?B?RGF2aWRS?=, Sep 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    509
    =?Utf-8?B?RGF2aWRS?=
    Sep 12, 2004
  3. Daves
    Replies:
    1
    Views:
    361
  4. Harry Zoroc
    Replies:
    1
    Views:
    915
    Gregory Vaughan
    Jul 12, 2004
  5. CrazyAtlantaGuy
    Replies:
    2
    Views:
    130
    CrazyAtlantaGuy
    Nov 30, 2005
Loading...

Share This Page