Professional Web Applications Themes

Accessing data on a SQL-server - ASP.NET General

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

  1. #1

    Default 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 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
    Søren Jensen Guest

  2. #2

    Default Re: Accessing data on a SQL-server

    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.P( cmd.ExecuteScalar().ToString() );
    cmd.Connection.Close();


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

    hth,
    Dave
    [url]www.aspNetEmail.com[/url]




    "Søren Jensen" <soren_a_28hotmail.com> wrote in message
    news:015101c34267$86707ed0$a501280aphx.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 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 Guest

Similar Threads

  1. Accessing Data through SWF on IIS5
    By peter.shankland in forum Macromedia Flash Data Integration
    Replies: 5
    Last Post: December 19th, 03:25 PM
  2. Replies: 31
    Last Post: June 25th, 11:29 PM
  3. Accessing SQL-Server data in XML
    By Vaibhav in forum ASP Database
    Replies: 0
    Last Post: June 14th, 09:45 AM
  4. Accessing Data
    By Mohan Gupta in forum ASP.NET Web Services
    Replies: 1
    Last Post: December 17th, 08:57 PM
  5. web services when accessing data
    By serkan ulucan in forum ASP.NET Web Services
    Replies: 0
    Last Post: October 2nd, 08:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139