Accessing data on a SQL-server

  • Thread starter =?iso-8859-1?Q?S=F8ren_Jensen?=
  • 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
 
D

dave wanta

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top