Accessing data on a SQL-server

  • Thread starter Thread starter =?iso-8859-1?Q?S=F8ren_Jensen?=
  • Start date Start date
?

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

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




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
 
Back
Top