473,320 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

To check whether the data exists in the back end or not

44
I have created a login form in asp.net web page.Just like that I have created a table named login which has 2 fields as username & password in SQL Server 2000. I have to check whether the data(username & password) entered in the front end is available(exists) in the back end (SQL Server 2000) or not.
Mar 10 '08 #1
2 1506
davidson1
144 100+
if the user enter

username in Textbox1
password in Textbox2

use this query
Expand|Select|Wrap|Line Numbers
  1. dim rd as new sqldatareader
  2.  
  3. dim cmd as new sqlcommand("select count(*) from login where username=' " & textbox1.text & " ' and password=' " & textbox2.text & " ' ",cn)
  4.  
  5. rd=cmd.executereader()
  6.  
  7. if rd(0)=0 then
  8.  
  9. Response.write("Invalid User")
  10. exit sub
  11. else
  12. Response.write("Valid User")
  13.  
  14. end if
  15.  
Davidson

10 march 2008
Mar 10 '08 #2
kunal pawar
297 100+
this is like assignment.

u have to following steps on login button click event

1) Declare connection and command object
Dim oSqlcon as SqlConection
Dim oSqlcmd as SqlCommand
2) Open connection
oSqlCon = New SqlConnection(connection string)
oSqlCon.Open()
3) create command object
oSqlCmd = new SqlCommand()

4) assing query and execute query
oSqlCmd.connection = oSqlcon
oSqlCmd.commandText = "select userid from userTable where loginname=' "& Trim( txtloginname.text ) &" ' and password= ' ''& Trim(txtPwd.text) &" ' "

Dim cnt as Int32
cnt = oSqlCmd.executescalar()
if cnt <=0 then
Response.write("Un-authorise user")
else
Response.write("Authorise user")
end if
Mar 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Joshua Weston | last post by:
I am new to C++ and I am very interested in becoming proficient. This post is two-fold. One, I am having problems with this small test program. It is meant to allow user input to control a "@"...
3
by: RAD | last post by:
I am working with an evaluation copy of SQL Server 2000 for the first time; my DB experience lies with MS Access. I have a simple table in SQL Server (tblCompany) that has a field called...
2
by: adam | last post by:
hello What query shoul I send to SQL serwer ( in transact SQL language ) to check does some database exist on serwer ? It similar to problem "does some table exist in database" - resolve to it...
7
by: andylcx | last post by:
Hi all: The c++ language can check whether the file exist or not. I am wondering how c language does this job? Thanks a lot! Andy
1
by: Onur Bozkurt | last post by:
Is there anyway to check if an e-mail address exists..... I mean someone entered a mail address in a form... I wan't to check if that e-mail reallly exists, doesn't matter if he/she really owns it....
5
by: sword | last post by:
How can I check whether a file exists?
3
by: byeung | last post by:
Hi, I am trying to check if a particular record already exists in an Access database through Excel vba code. Through code obtained at another forum, I got the following: ...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
3
Maidenz08
by: Maidenz08 | last post by:
How do i check whether an email id exists or not? I am following a three step validation process.. 1) syntax validation- which is pretty straight forward 2) DNS validation - I'm able to do...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.