|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Strange Issue / DB Error / Not Showing Error MessageI 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 *** Sent via Developersdex http://www.developersdex.com *** 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 Ivan Weiss wrote: Show quoteHide quote > 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 > > *** Sent via Developersdex http://www.developersdex.com *** 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 *** Sent via Developersdex http://www.developersdex.com *** > UserRole = oleReader(0) What is UserRole? Also is this the line that is throwing the error? Ifnot which line is? Thanks, Seth Rowe Ivan Weiss wrote: Show quoteHide quote > 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 > > *** Sent via Developersdex http://www.developersdex.com *** 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 *** Sent via Developersdex http://www.developersdex.com *** > 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 Ivan Weiss wrote: Show quoteHide quote > 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 > > *** Sent via Developersdex http://www.developersdex.com *** 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 *** Sent via Developersdex http://www.developersdex.com *** Ah ha! Some error messages! First, make sure that the username and
password variables in your SQL statement aren't nothing (or try hardcoding them in just to narrow down issues). If that all fails, rebuild your SQL statement using OleDb parameters. Here's a link to Cor Ligthert and Ken Tuckers sight that has sample code: http://www.vb-tips.com/dbpages.aspx?ID=550279ec-6767-44ff-aaa3-eb8b44af0137 Hope that helps, Seth Rowe Ivan Weiss wrote: Show quoteHide quote > 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 > > *** Sent via Developersdex http://www.developersdex.com *** Ivan Weiss wrote:
> PS---> I cant find that patch to resolve the virusscan issue other than Patch 5 for McAfee VirusScan Enterprise 8.0i> manually disabling buffer overrun so if anyone has it or knows > specifically where to get it that would help! Direct download for the patch: http://sdownload.nai.com/products/protected/hotfix/VSE80P05.Zip 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 *** Sent via Developersdex http://www.developersdex.com *** 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 Ivan Weiss wrote: Show quoteHide quote > 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 > > *** Sent via Developersdex http://www.developersdex.com *** Ivan Weiss wrote:
> Good morning all, Do you, by chance, run McAfee Virus Scanner? That can cause the> > 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. > 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 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 *** Sent via Developersdex http://www.developersdex.com *** Ivan Weiss wrote:
> Chris, http://tinyurl.com/k8jgx> > 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 > > *** Sent via Developersdex http://www.developersdex.com ***
VB.NET equivalent of C# Operator '??'
Using For Each in a Custom collection class with hashtables Compiling for .NET Framework 1.x in VS 2005 How to open a .CSV file ? Moving Forms Search for Directories/files/Folders When "As New" or not when instantiating? Sql server express 2005 connections open DataTable - Date Difference "using statments" |
|||||||||||||||||||||||