if dr.HasRows ' in Version 1.1 of the Framework
Do While dr.Read
Response.Write("User Name = " & dr("UserName"))
Response.Write("Password = " & dr("Password"))
Loop
Else
Response.Write ("No user info on file...")
End if
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
MVP, hRD
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
"IbrahimMalluf" <Ib*****@malluf.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
add theses lines to code:
"Matt" <ma*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... I just want to get the value of field UserName and Password in
SqlDataReader object dr. But it yeields run-time error "Invalid attempt to read when
no data is present" on line dr("UserName") and dr("Password")
any ideas??
Dim sql As String = "select * from [Admin] where UserName = '" &
TextBox1.Text & "'" _
& "AND Password = '" & TextBox2.Text & "'" & ";"
Dim cmd As New SqlCommand(sql, cn)
cmd.Connection.Open()
Dim dr As SqlDataReader
dr = cmd.ExecuteReader()
Response.Write("User Name = " & dr("UserName"))
Response.Write("Password = " & dr("Password"))