473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem with accessing function in page load Method

37
Hi All,

I am having a problem with accesing function in the page. i have a page say user.aspx in the page load method
i am calling function to validate the user.


it works fine when single user access the page but when another user try to access the page then it crash the
first users processing and empty the session variable.

means when i am calling function in the page load of user.aspx then it is giving me problem.
and if i write user validation code direct in page load method then it works fine.

problem occurs only when i write user validation code in function and try to call that function in page load of
user.aspx

Expand|Select|Wrap|Line Numbers
  1.  Private Sub Page_Load
  2.  
  3.  
  4.  
  5.       IF validateUser() THEN      
  6.  
  7.               Response.write ("Welcome" & sUserID )
  8.     Else
  9.             Response.Redirect("UserNotFound.aspx?userid=" & sUserID & "&Form=DataXS")
  10.        End If
  11.  
  12.  
  13.  End sub
  14.  
  15.  
  16.  Public Function validateUser() as boolean
  17.  
  18.     Dim dbOleDbDataReader As OleDbDataReader
  19.     dim bflag as boolen
  20.  
  21.                         sSQL = "Select NAME From kuaf where lower(NAME)='" & LCase(sUserID) & "' 
  22.  
  23.                         Dim sConnectionString As String = xsData.getDatabaseConnection(sLogFile)
  24.                         Using dbConnection As New OleDbConnection(sConnectionString)
  25.                             Dim dbcommand As New OleDbCommand(sSQL, dbConnection)
  26.                             dbcommand.CommandType = CommandType.Text
  27.                             dbcommand.Connection.Open()
  28.                             dbOleDbDataReader = dbcommand.ExecuteReader()
  29.  
  30.                             If Not dbOleDbDataReader Is Nothing Then
  31.                                 If dbOleDbDataReader.Read() Then
  32.                     bflag = True
  33.                                 Else
  34.                                     Response.Redirect("UserNotFound.aspx?userid=" & sUserID & "&Form=DataXS")
  35.                                 End If
  36.                             End If
  37.  
  38.                             dbOleDbDataReader.Close()
  39.                             dbOleDbDataReader = Nothing
  40.                             dbcommand.Dispose()
  41.                             dbcommand = Nothing
  42.                             dbConnection.Close()
  43.                         End Using
  44.  
  45.     Return bflag 
  46.  
  47.  End Function 
can u tell me why it is happening..

Thanks

-Joseph
Sep 8 '08 #1
1 1444
kenobewan
4,871 Expert 4TB
If boolean value true or false. Return result first and then test whether the result is t or f. However I notice you have a typo in declaring bflag.
Sep 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: WFB | last post by:
Hi, I have a base class from which all of my pages derive (ABCBasePage). For example, ABCCustomerSelect Inherits ABCPasePage. I would now like to have ABCPocketSelect which should inherit from...
5
by: Asa Monsey | last post by:
I am having a problem that the page load event fires twice in reponse to an autopostback. The first time, the IsPostBack property is true, and the second time it it false. This is causing many...
7
by: UJ | last post by:
I've got a page with a user control on it. While the page is loading, it needs to check certain conditions of the user object to enable/disable things on the screen. Currently in the page_load of...
15
by: H00ner | last post by:
Hello All Hope you can help Been pulling my hair out about a popup problem in ASP.NET. One of the forms i wrote requires the user to select a product from a list in a popup web form. the...
3
by: Jason | last post by:
I have an ASP.NET application in which I would like to call my button click event (imgSubmitSearch_Click) on the page load if certain criteria are met. Is this possible? What is the correct...
0
by: R.A.M. | last post by:
Hi, Could you help me please with a problem of infinite page load? I have an ASP.NET page (texts in Polish; meaning not important): <%@ Page Language="C#" AutoEventWireup="true"...
0
by: manywolf | last post by:
I have an aspx page that fires the page load event twice for every load. I tried every fix that was suggested in all the posts on this and other forums. None changed the behavior. After one post that...
1
by: deepakbarolia | last post by:
hi, i am working on dotnet. I have a pop up window opening from the basepage. The pop up window contains only datagrids and a button. On page load i need to point to the top of the page. The...
1
by: ahmh | last post by:
The javascript function is called getsportart2 in the codebehind page_load I have the following Page.RegisterStartupScript("MyScript3","<script type='text/javascript'...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.