Login Page Database connection to MSAccess

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 13
Reputation: bravo659 is an unknown quantity at this point 
Solved Threads: 0
bravo659 bravo659 is offline Offline
Newbie Poster

Login Page Database connection to MSAccess

 
0
  #1
May 15th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Login Page Database connection to MSAccess

 
0
  #2
May 16th, 2005
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
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 13
Reputation: bravo659 is an unknown quantity at this point 
Solved Threads: 0
bravo659 bravo659 is offline Offline
Newbie Poster

Re: Login Page Database connection to MSAccess

 
0
  #3
May 16th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Login Page Database connection to MSAccess

 
0
  #4
May 17th, 2005
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!


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.
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 812
Reputation: arjunsasidharan is on a distinguished road 
Solved Threads: 13
arjunsasidharan's Avatar
arjunsasidharan arjunsasidharan is offline Offline
Practically a Posting Shark

Re: Login Page Database connection to MSAccess

 
0
  #5
Aug 5th, 2006
well i tried n it didn work.. wher shud i write tht code line??
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4
Reputation: decklon is an unknown quantity at this point 
Solved Threads: 0
decklon decklon is offline Offline
Newbie Poster

Re: Login Page Database connection to MSAccess

 
0
  #6
May 3rd, 2007
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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4
Reputation: decklon is an unknown quantity at this point 
Solved Threads: 0
decklon decklon is offline Offline
Newbie Poster

Re: Login Page Database connection to MSAccess

 
0
  #7
May 3rd, 2007
how do i change background image on a command button at a runtime? Thanx
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 812
Reputation: arjunsasidharan is on a distinguished road 
Solved Threads: 13
arjunsasidharan's Avatar
arjunsasidharan arjunsasidharan is offline Offline
Practically a Posting Shark

Re: Login Page Database connection to MSAccess

 
0
  #8
May 5th, 2007
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)
There is just two ways to live your life.
One is as though nothing is a miracle.
The other is as if everything is.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4
Reputation: decklon is an unknown quantity at this point 
Solved Threads: 0
decklon decklon is offline Offline
Newbie Poster

Re: Login Page Database connection to MSAccess

 
0
  #9
May 5th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1
Reputation: vineet sikarvar is an unknown quantity at this point 
Solved Threads: 0
vineet sikarvar vineet sikarvar is offline Offline
Newbie Poster

Re: Login Page Database connection to MSAccess

 
0
  #10
Aug 16th, 2007
[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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC