Strange Issue / DB Error / Not Showing Error Message

I

Ivan Weiss

Good morning all,

I am trying to access an access database to authenticate users upon
logging into my application.

Something is throwing an excecption. My error handling code should
display this message in a msgbox. However, the messagebox is always
empty.

Here is my error handling code.

Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OKOnly)
Finally
oleConn.Close()
End Try

Return bolTemp
End Function

Am I missing something? Do I have to include any system libraries for
error handling? Very confusing.....

Thanks in advance!

-Ivan
 
R

rowe_newsgroups

If you step through the code, when entering the Catch block the ide's
exception helper should pop up if you hover over "catch ex as
exception" line. See if that gives any additional information. If that
doesn't help solve the problem then what code is causing the error?

Thanks,

Seth Rowe
 
C

Chris Dunaway

Ivan said:
Good morning all,

I am trying to access an access database to authenticate users upon
logging into my application.

Something is throwing an excecption. My error handling code should
display this message in a msgbox. However, the messagebox is always
empty.

Do you, by chance, run McAfee Virus Scanner? That can cause the
message box to be blank. They have released a patch to fix the
problem.

If you search these groups, you should find more information on it as
it pops up occaisionally.

Chris
 
I

Ivan Weiss

Chris,

I do happen to have Mcafee Virus Scan installed. I could not find
anything on that. Do you happen to know where I can get the patch. I
tried searching on Mcafee web site as well...

-Ivan
 
I

Ivan Weiss

Seth,

It did not display any further information.

Here is the code: It is a function within a User class that I am using
to authenticate my user that is logging in. I simply put in a user name
and a password and hit submit and it references this class:

Public Function ValidUser(ByVal UserName As String, ByVal Password As
String) As Boolean
Dim bolTemp As Boolean = False

Try
strSQL = "SELECT Roles FROM Employees WHERE (UserName = " &
UserName & ") AND (Password = " & Password & ")"
oleConn = New OleDbConnection(strConString)
oleCmd = New OleDbCommand

oleConn.Open()

With oleCmd
.CommandText = strSQL
.CommandType = CommandType.Text
.Connection = oleConn
oleReader = .ExecuteReader(CommandBehavior.SingleRow)
End With

While oleReader.Read
bolTemp = True
UserRole = oleReader(0)
End While

oleReader.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OKOnly)
Finally
oleConn.Close()
End Try

Return bolTemp
End Function


-Ivan
 
R

rowe_newsgroups

UserRole = oleReader(0)

What is UserRole? Also is this the line that is throwing the error? If
not which line is?

Thanks,

Seth Rowe
 
I

Ivan Weiss

UserRole is a property:

Public Property UserRole() As String
Get
If strUserRole <> "" Then
Return strUserRole
Else
MsgBox("You are not Logged in. System will Exit.
Restart and Login")
Application.Exit()
End If
End Get
Set(ByVal Value As String)
strUserRole = Value
End Set
End Property

After this line is run, it goes to the error handling code so this must
be the culpret but I have no clue why:

oleReader = .ExecuteReader(CommandBehavior.SingleRow)

-Ivan
 
R

rowe_newsgroups

oleReader = .ExecuteReader(CommandBehavior.SingleRow)

Let's pull this out of the with block and drop the parameter.

i.e.

oleReader = objCmd.ExecuteReader()

Also I didn't see anywhere that you dimensioned the oleReader object.
Is this done somewhere other than in the code you supplied?

Thanks,

Seth Rowe
 
I

Ivan Weiss

Hi Seth,

That Mcafee issue did solve the disappearing message box screen and now
I am getting some actual errors.

Adjusting the olereader outside of the With block and removing the
parameter did not help.

Here is the general dimensioning of variables for the class. It is
coded prior to any properties or subs

Private strConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Documents and Settings\iweiss\My Documents\elite.mdb;User
Id=admin;Password=;"
Private oleCmd As OleDbCommand
Private oleConn As OleDbConnection
Private oleReader As OleDbDataReader
Private strUserRole As String = ""
Private strSQL As String = ""

The errors in the message box are as follows:

"No Value given for one or more required parameters."

Thanks for your help thus far.

PS---> I cant find that patch to resolve the virusscan issue other than
manually disabling buffer overrun so if anyone has it or knows
specifically where to get it that would help!

-Ivan
 
I

Ivan Weiss

Seth,

I am not sure I understand what you are suggesting. I tried hard coding
the values as well as double checking my SQL statement. It is as I want
it.

Wouldnt I want to avoid using a dataset due to memory reasons? I am
only looking to return one record (the roles of the Authenticated user)
as well as confirming they are a real user.

I am unfamiliar with how to access information within a dataset so I
guess I would not know in what direction to go from the sample you sent
me....

-Ivan
 
R

rowe_newsgroups

For some reason the OleDb handler is throwing out one of your
parameters (either UserName or Password). The suggestion to hard code
the values, therefore bypassing the parameters. In the event that
failed (which apparently it did) you could use the sample in the link I
provided to add the username and password through oledb parameters. I
gave the link to show how to use parameters, not instructing you to use
a dataset. You should definately still use a datareader to grab the
data. Let me know if that helps.

Thanks,

Seth Rowe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top