Click here to Skip to main content
15,893,814 members
Home / Discussions / Database
   

Database

 
GeneralRe: Question concerning Sorting DataGrids Pin
Dominic Farr28-Jun-05 20:03
Dominic Farr28-Jun-05 20:03 
GeneralRe: Question concerning Sorting DataGrids Pin
Dominic Farr30-Jun-05 6:51
Dominic Farr30-Jun-05 6:51 
Questionupdateable query? Pin
Jerry Hammond15-May-05 4:56
Jerry Hammond15-May-05 4:56 
AnswerRe: updateable query? Pin
anj198315-May-05 5:20
anj198315-May-05 5:20 
GeneralTimeSpan instead of DateTime in a DataSet populated from a SQL Anywhere DB Pin
JasonJB14-May-05 4:38
JasonJB14-May-05 4:38 
GeneralGenerate Auto Number in SQL server 2000 Pin
imshally8114-May-05 0:42
imshally8114-May-05 0:42 
GeneralRe: Generate Auto Number in SQL server 2000 Pin
Colin Angus Mackay14-May-05 3:55
Colin Angus Mackay14-May-05 3:55 
GeneralLogin page Pin
Desi Bravo13-May-05 12:38
Desi Bravo13-May-05 12:38 
I created a user login page associated with an address book. In order to retrieve the address book the user must enter the username and password. How can i code the login button for authentication.
Below is the code that i used but there is an error message that points to ExecuteReader. Error: "ExecuteReader requires an open and available connection. The connection current state is closed."

I am using the OleDbDataAdapter, OleDbDataReader, OleDbConnection, and the OleDbCommand. What is it that I am doing wrong. I also created a MS Access table.

Dim mypath = Application.StartupPath & "\password.mdb"
Dim Password = ""
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mypath & ";Jet OLEDB:Database Password=" & Password)
Dim cmd As OleDbCommand

Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim sql = "SELECT Username,Password FROM Password WHERE Username = '" & txtUsername.Text & "' AND Password = '" & txtPassword.Text & "'"

cmd = New OleDbCommand(sql, conn)
Dim dr As OleDbDataReader = cmd.ExecuteReader
If conn.State <> ConnectionState.Open Then
conn.Open()
End If

Try
conn.Open()

Catch ex As InvalidOperationException
MsgBox(ex.Message)

End Try
Try
If dr.Read = False Then
MessageBox.Show("Authentication Failed...")
Else
MessageBox.Show("Login Successful...")

End If
Catch ex As Exception
MsgBox(ex.Message)

End Try

If conn.State <> ConnectionState.Closed Then
conn.Close()

End If


Dim form As New Form2
form.Show()




bravo659
GeneralRe: Login page Pin
MoustafaS13-May-05 14:34
MoustafaS13-May-05 14:34 
GeneralRe: Login page Pin
Desi Bravo14-May-05 19:55
Desi Bravo14-May-05 19:55 
GeneralRe: Login page Pin
MoustafaS15-May-05 0:32
MoustafaS15-May-05 0:32 
GeneralRe: Login page Pin
Desi Bravo16-May-05 15:35
Desi Bravo16-May-05 15:35 
GeneralRe: Login page Pin
jonathan1516-May-05 1:59
jonathan1516-May-05 1:59 
GeneralRe: Login page Pin
Colin Angus Mackay16-May-05 6:08
Colin Angus Mackay16-May-05 6:08 
GeneralRe: Login page Pin
Desi Bravo16-May-05 15:34
Desi Bravo16-May-05 15:34 
GeneralRe: Login page Pin
Colin Angus Mackay16-May-05 22:04
Colin Angus Mackay16-May-05 22:04 
GeneralSqlDataReader Pin
Member 195262813-May-05 6:35
Member 195262813-May-05 6:35 
GeneralRe: SqlDataReader Pin
Colin Angus Mackay13-May-05 6:56
Colin Angus Mackay13-May-05 6:56 
GeneralRe: SqlDataReader Pin
Member 195262813-May-05 7:12
Member 195262813-May-05 7:12 
GeneralRe: SqlDataReader Pin
Albert Pascual13-May-05 13:27
sitebuilderAlbert Pascual13-May-05 13:27 
GeneralRe: SqlDataReader Pin
Colin Angus Mackay13-May-05 21:54
Colin Angus Mackay13-May-05 21:54 
GeneralRe: SqlDataReader Pin
Albert Pascual16-May-05 5:35
sitebuilderAlbert Pascual16-May-05 5:35 
GeneralRe: SqlDataReader Pin
Colin Angus Mackay16-May-05 5:42
Colin Angus Mackay16-May-05 5:42 
GeneralRe: SqlDataReader Pin
Albert Pascual16-May-05 5:56
sitebuilderAlbert Pascual16-May-05 5:56 
GeneralRe: SqlDataReader Pin
Colin Angus Mackay16-May-05 6:00
Colin Angus Mackay16-May-05 6:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.