i am trying to make a simple login form using OleDb
i am getting a single error that the "dr" does not have a constructor

default.aspx.vb

Imports System.data
Imports System.Data.OleDb
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\jensen\My Documents\login.mdb;Persist Security Info=True")
        cn.Open()
        Dim cmd As New OleDbCommand("Select user,pass,Type from login Where user= '" & tb_user.Text & "' AND pass = '" & tb_pass.Text & "' AND Type= '" & tb_type.Text & "'", cn)
        Dim dr As New OleDbDataReader
        dr = cmd.ExecuteReader()
        dr.Read()
        If dr.Read = True Then
            MsgBox("verification successfull")
        Else
            MsgBox("invalid username")
        End If
        cn.Close()

    End Sub
End Class

when the error is clicked it goes to "dim dr as new OleDbDataReader"
please am a beginner
thanks in advance
<EMAIL SNIPPED>

Hmm I may be wrong but...
Try Semething like this.

"SELECT [user],[Pass],[Type] FROM [login] WHERE ([user] ='" & tb_user.Text & "' AND Pass='" & tb_pass.text &
 "' AND Type='" & tb_type.text & "')"

As i said i'm not sure if this will work but... it is better than nothing

Also i'm unsure if you can combine more than one column on a reader. i'm somewhat of a newbie also

Also edit your code and make your select query in a string like so

Dim str As String = "SELECT [user],[Pass],[Type] FROM [login] WHERE ([user] ='" & tb_user.Text & "' AND Pass='" & tb_pass.text &
 "' AND Type='" & tb_type.text & "')"
 Dim cmd As New OleDbCommand(str,cn)

It looks a little neater.
Then if you want to catch the error before you read any lines, use the Try/Catch function built in with vs. It will automatically send info backt o you on the page.
For example:

Try
  dr.Read()
        If dr.Read = True Then
            MsgBox("verification successfull")
        Else
            MsgBox("invalid username")
        End If
        cn.Close()
Catch ex as Exception
       Response.write(ex)
       End Sub
End Try
This article has been dead for over six months. Start a new discussion instead.