| | |
Error message when passing property changes between forms
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2005
Posts: 4
Reputation:
Solved Threads: 0
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 OLEDB
atabase 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 OLEDB
ystem databas" & _
"e=;Jet OLEDB
FP=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 OLEDB
on'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
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 OLEDB
atabase 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 OLEDB
ystem databas" & _"e=;Jet OLEDB
FP=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 OLEDB
on'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
- Toshiba IDE1 error message (Windows NT / 2000 / XP)
- Perl Error Message-assistance requested (Perl)
- Wierd Error message. (ASP.NET)
- MERGED: Hardware/Driver Problems-Error Message (Windows 95 / 98 / Me)
- Error message when running ASP email script (ASP)
- wupdater.exe error message (Web Browsers)
- Please help with DLL error message! (Windows NT / 2000 / XP)
Other Threads in the VB.NET Forum
- Previous Thread: Where do my programs reside?
- Next Thread: Problem in streaming media files in the embedded Windows Media Player
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google hardcopy html images input insert intel internet mobile monitor ms net networking objects open output panel passingparameters pdf picturebox picturebox1 port position printing problem project save searchbox searchvb.net select serial settings shutdown soap sqlserver survey tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet view visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





