i have two textboxes one for user name and another for
password . i have a table name compare(which contains
name,passwod etc.,)my doubt is how compare username
textbox with name column and how compare password textbox
with passwod column. i want the code

Answer Posted / sonj

dim qry as string = SELECT name,password FROM compare where
name = '" + txtName.text + "' AND password = '" +
txtPassword.txt + "'"

Dim ConectionString As String = "User ID=xxx;Password = yyy;
Initial Catalog='" + DataBaseName + "';Data Source=<System No>"

dim con as SqlConnection = New SqlConnection(ConectionString )
con.open

dim cmd as SqlCommand = new SqlCommand(qry,con)
dim dr as SqlDataReader = cmd.ExectueReader

if dr.HasRows = True then
messagebox.show("User ID Found")
else
messagebox.show("User ID Not Found")
end if

Above is the one example. There are various ways to validate
fox example you can write a stored procedure to validate
ID,Password and avoid SQL Injection etc.,

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between Data adaptor and Data set?

508


Do you use stored procedure in ado.net?

540


Explain how to create dynamic gridview?

512


What are the advantages and disadvantages of using datalist?

521


What is the role of clr?

525






What is ado.net code?

515


Is it possible to load multiple tables in a Dataset?

522


What is the difference between DataReader and DataSet in ADO.NET?

585


How can we serialize the dataset object?

555


What is a serialized object?

532


How can I retrieve two tables of data at a time by using data reader?

507


In how many ways we can retrieve table records count? How to find the count of records in a dataset?

536


What is ado.net connection?

457


What is the use of ADO.NET and XML web services?

586


How to aggregating data across related tables?

545