944,025 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 53382
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
May 15th, 2005
0

Login Page Database connection to MSAccess

Expand Post »
I been working on this login page for months, and to no avail can have the program working. I am using the MSAccess Database and using VB.Net. This is a windows application creating a login page. The following is the code that I been working on:
Dim mypath = Application.StartupPath & "\password.mdb"
Dim Password = ""
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Documents and Settings\Owner\My Documents\OLEDB\password.mdb")
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


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()

End Sub

The above code generates an error that points to the cmd.ExecuteReader
It says that the error : "ExecuteReader requires an open connection and available connection. The connection's current state is closed."
How can I use the open state for the ExecuteReader?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
bravo659 is offline Offline
27 posts
since May 2005
May 16th, 2005
0

Re: Login Page Database connection to MSAccess

OK well the error is telling you exactly what is wrong. ExecuteReader requires an open connection and available connection

You need to add this line of code before you ExecuteReader. conn.Open()


Hope this helps
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
May 16th, 2005
0

Re: Login Page Database connection to MSAccess

Quote originally posted by Paladine ...
OK well the error is telling you exactly what is wrong. ExecuteReader requires an open connection and available connection

You need to add this line of code before you ExecuteReader. conn.Open()


Hope this helps
I really did because I tried it, and was missing in my coding. It is fixed and running good. I just need to be caredful how i code. The error message really drove me crazy, and thanks to you developers that assisted me in correcting my code. I will practice more. Now I am trying to learn the Stored Procedures.
Find it difficult, but will continue on it.
Reputation Points: 10
Solved Threads: 0
Light Poster
bravo659 is offline Offline
27 posts
since May 2005
May 17th, 2005
0

Re: Login Page Database connection to MSAccess

Glad it worked

If you have troubles with Store Procedures or anything in SQL/Access just post on the forums, someone will be glad to help!


Quote originally posted by bravo659 ...
I really did because I tried it, and was missing in my coding. It is fixed and running good. I just need to be caredful how i code. The error message really drove me crazy, and thanks to you developers that assisted me in correcting my code. I will practice more. Now I am trying to learn the Stored Procedures.
Find it difficult, but will continue on it.
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Aug 5th, 2006
0

Re: Login Page Database connection to MSAccess

well i tried n it didn work.. wher shud i write tht code line??
Reputation Points: 347
Solved Threads: 13
Practically a Posting Shark
arjunsasidharan is offline Offline
812 posts
since Aug 2006
May 3rd, 2007
-1

Re: Login Page Database connection to MSAccess

This codes works. I also need to fetch the user's full name and the account type into a variable, in order to be able to welcome the user by his full name. How do i do that? Thanx
Reputation Points: 10
Solved Threads: 0
Newbie Poster
decklon is offline Offline
4 posts
since May 2007
May 3rd, 2007
0

Re: Login Page Database connection to MSAccess

how do i change background image on a command button at a runtime? Thanx
Reputation Points: 10
Solved Threads: 0
Newbie Poster
decklon is offline Offline
4 posts
since May 2007
May 5th, 2007
0

Re: Login Page Database connection to MSAccess

i guess you can do that in the form_load event.

Call the button in the load event

button1.image = (the path where you have the image of the button or place it in the bin)
Reputation Points: 347
Solved Threads: 13
Practically a Posting Shark
arjunsasidharan is offline Offline
812 posts
since Aug 2006
May 5th, 2007
0

Re: Login Page Database connection to MSAccess

I have a form (frmLogin) on which i have 4 command button n 1 is btnLogIn. so need to change the image on the btnLogIn after the user has logged In.

i had wanted to use something like imageList. Plz help
Thanx
Reputation Points: 10
Solved Threads: 0
Newbie Poster
decklon is offline Offline
4 posts
since May 2007
Aug 16th, 2007
0

Re: Login Page Database connection to MSAccess

[i have problem with that code could u plz send me the correct code to my e-mail id that is <snipped email> i will be very thankfull of you
Last edited by Ancient Dragon; Aug 18th, 2007 at 7:53 am. Reason: removed email
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vineet sikarvar is offline Offline
1 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: how to see the folder contents
Next Thread in VB.NET Forum Timeline: Error in displaying the stored procedure





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC