I am following the code in a previous thread and cannot access SQL database. See attached login.aspx and login.aspx.vb files. Database file is a simple "Users" filw with AutoID, username, email and password. What am I doing wrong? Any help is greatly appreciated.

I guess to start with...

What, if any, errors are you receiving when you attempt to run this code? This might help to narrow down the specific components of the code to look at.

Hi! I receive no errors, just that the system kicks me back to the login page with "username" field filled.

I'm sorry, I did my best to wade through your code but I'm not much on VB. Hopefully someone with more in-depth knowledge of VB and SessionStates will be able to toss back an answer on this one for you.

Ok thanks anyway.

you r passing arguments while calling Function DbConnection()
but you not specified any argument while defining it

rty this code for login it properly works for me as i updated for you.

Dim strConn As String
        strConn = WebConfigurationManager.ConnectionStrings("iPesha").ConnectionString
Dim Conn As New SqlConnection(strConn)
        Conn.Open()
Dim sqlUserName As String= "SELECT UserName,Password FROM Users "
cmd =new sqlCommand(sqlUserName,con)
dim dr as SqldataReader
dr=cmd.ExecuteReader()
if dr.HasRows=true then
    While(dr.Read())
       If dr(1).ToString() = username And dr(2).ToString() = pwd Then
       Session("UserAuthentication") = username
       end if
    end while
    Response.Redirect("JobSearch.aspx")
elseif dr.HasRows=False then
     Session("UserAuthentication") = ""
end if

That solved the problem. Thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.