Accessing data on a SQL-server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Søren Jensen

    #1

    Accessing data on a SQL-server

    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 databaseconnect ion.

    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

    #2
    Re: Accessing data on a SQL-server

    you mean like this?
    (off the top of my head )
    string connectionStrin g = "{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.ExecuteScal ar().ToString() );
    cmd.Connection. Close();


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

    hth,
    Dave





    "Søren Jensen" <soren_a_28@hot mail.com> wrote in message
    news:015101c342 67$86707ed0$a50 1280a@phx.gbl.. .
    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 databaseconnect ion.

    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


    Comment

    Working...