944,014 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 4742
  • VB.NET RSS
Apr 29th, 2005
0

Error message when passing property changes between forms

Expand Post »
I am working on a login password. I want my front page to load and then the password form to appear. The user then types in userid and password - if correct the login form closes. I want the front page to remain visible behind the login form BUT - I dont want the user to be able to use any buttons on the Front Page until after login is complete.

I have the Front Page Enabled = False at Load. I want it to go to Enable = True after Login is complete. I want to pass the change in Enable from my login form to my front page form. (can it be done?)

I am getting an error (I have tried using .focus and get the same error )

An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication1.exe

Additional information: Object reference not set to an instance of an object.
(*** = where error is occuring)

login form

Public Class frmMgtLogin
Inherits System.Windows.Forms.Form

Dim UP As New OleDb.OleDbCommand
Dim Con As New OleDb.OleDbConnection
Dim Read As OleDb.OleDbDataReader
Dim Plus As Integer
Public CurrentForm As System.Windows.Forms.Form

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If txtUserName.Text.Trim = "" Then
MessageBox.Show("Please fill your User Name !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
txtUserName.Focus()
Exit Sub
End If

'if textbox2 is blank then ...
If txtPassword.Text.Trim = "" Then
MessageBox.Show("Please fill your Password !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
txtPassword.Focus()
Exit Sub
End If

'Admin
UP.Parameters.Add("user", Data.OleDb.OleDbType.Variant)
UP.Parameters.Add("password", Data.OleDb.OleDbType.Variant)

UP.Parameters("user").Value = txtUserName.Text
UP.Parameters("password").Value = txtPassword.Text


'Open database connection
Con.Open()

' Read information from database
Read = UP.ExecuteReader

ar()

' Close database connection
Con.Close()

End Sub

Private Sub ar()
With Read
If .Read Then
Me.Close()
Dim CurrentForm As FrontPage
*** CurrentForm.Enabled = True
CurrentForm.Show()

Else
Plus += 1

If Plus >= 3 Then
MessageBox.Show("Sorry, too many error !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
'Close application
End
Else

txtUserName.Clear()
txtPassword.Clear()


MessageBox.Show("Invalid User Name or Password !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Error)
End If
End If
txtUserName.Focus()
End With
End Sub

Private Sub frmMgtLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Connection string
'Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "Pas.mdb;Mode=ReadWrite;Persist Security Info=False"

Con.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDBatabase L" & _
"ocking Mode=1;Data Source=""C:\Documents and Settings\Owner\My Documents\Visual S" & _
"tudio Projects\WindowsApplication1\ConsignmentShop.mdb"";Mode=Share Deny None;Jet" & _
" OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDBystem databas" & _
"e=;Jet OLEDBFP=False;persist security info=False;Extended Properties=;Jet OLED" & _
"B:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLED" & _
"B:Create System Database=False;Jet OLEDBon't Copy Locale on Compact=False;User" & _
" ID=Admin;Jet OLEDB:Global Bulk Transactions=1"

UP.Connection = Con
UP.CommandType = CommandType.Text
UP.CommandText = "Select * From UserLogin Where UserID =? and PassID =?"


End Sub


End Class
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Anine is offline Offline
4 posts
since Apr 2005

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: Where do my programs reside?
Next Thread in VB.NET Forum Timeline: Problem in streaming media files in the embedded Windows Media Player





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


Follow us on Twitter


© 2011 DaniWeb® LLC