Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass and return value under 3-tier environmen t issue

Status
Not open for further replies.

JFFUNG

Technical User
Apr 15, 2012
4
HK
Hi all,
I having a problem when I passing value and return value under 3 tier environment as below:

Goal: The UName is the username, I want to pass the username into database and run sql query to find out a new value then return to presentation layer with Label2.text to display.

Problem: Actually, I used a MessageBox can display a correct value whereas there is no any response or change for Label2

Presentation Layer:
Imports System
Partial Public Class cshome
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Dim UName As String = Request.QueryString("UName")
Label1.Text = UName
Loadtotalvalue()
End Sub

Sub Loadtotalvalue()
Dim BLLCS As New BLL_cs()
Dim TempRecord As Integer = 0
Dim UName As String = Request.QueryString("UName")
Try
TempRecord = BLLCS.PassName(UName)
Catch ee As Exception
Finally
BLLCS = Nothing
End Try
End Sub

Public Function getval(ByVal totalvalue As String)
Try
MsgBox(totalvalue)
Return Label2.Text = totalvalue
Return totalvalue
Catch ex As Exception
End Try
End Function[/color]


Businuess Login Layer:
Public Class BLL_cs
Inherits System.Web.UI.Page
Public Function passName(ByVal UName As String)
Dim dalcs As New DAL_cs()
Try
Return dalcs.loadtotalbooking(UName)
Catch ex As Exception
Finally
dalcs = Nothing
End Try
End Function

Public Function getvalue(ByVal totalvalue As String)
Dim ccshome As New cshome
Try
Return ccshome.getval(totalvalue)
Catch ex As Exception
ccshome = Nothing
End Try
End Function


Data Access Layer:
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient

Public Class DAL_cs
Inherits System.Web.UI.Page
Public Function loadtotalbooking(ByVal UName As String)
Dim totalvalue As String
Dim connStr, selectCmd As String
selectCmd = "select count (*) as total_record from Booking where CSUserName = '" & UName & "'"
connStr = "Data Source=CTU-PC\SQLEXPRESS;Initial Catalog=DCS_DB;Integrated Security=True"
Dim conn As SqlConnection, cmd As SqlCommand, myReader As SqlDataReader
conn = New SqlConnection(connStr)
Dim myDataSet As DataSet = New DataSet()
conn.Open()
cmd = New SqlCommand(selectCmd, conn)
myReader = cmd.ExecuteReader
If myReader.Read() Then
totalvalue = myReader("total_record")
Try
Dim passtoBLL As New BLL_cs
Return passtoBLL.getvalue(totalvalue)
Return totalvalue
Catch ex As Exception
End Try
End If
End Function
End Class
 
Who can answer my question?
How can return the value to presentation layer and display it?
Many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top