Asp.Net News
Free Tech Magazines
Asp.Net Web Hosting
Suggest Us
Link to Us
Feeds Subscription
Questions & Answers
Tips & Tricks
 update table in using
Posted by sunnyukeachu on  12/29/2011 8:51:50 AM Category: Asp.Net 2.0
Add to my favorites
Email to friend
1. I am using Visual Studio 2010 and MSSQL 2005. 2. I am developing a web interface for already exiting application to enable certain internal customers login and retrieve their own data. 3. They will check the retrieved data to be sure the existing data is ok as captured. 4. If it needs modification, they will go ahead to modify the retieved data on the controls on the form. 5. When done, they will submit for update. The submit event should UPDate tblEmployeeInformation table and INSERT audit trail in the tblAuditTrailHuresLive. 6. If it goes through, the modified data should be displayed for confirmation. 7. When done, they will use confirm button to certify the displayed data. 8. Each form should keep session which can terminate after 5minutes of idle time.

code behind for BIO-Data Form:
Collapse | Copy Code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

' This code executes when the page is first loaded.
If Session("empcode") <> "" Then
lblStaffCode.Text = Session("empcode")
staffid = CInt(lblStaffCode.Text)
lblUserName.Text = globalusername
sqlstr = "SELECT Surname,Firstname,Middlename,Initials,DOBDay,DOBMonth,DOBYear,Sex,MaritalStatus,BloodGrp,Genotype,PlaceofBirth,HomeTown,State,LGA,Nationality,Religion FROM tblEmployeeInformation WHERE EmpCode='" & staffid & "'"
End If
End Sub

Private Sub displayrecord()
'This retrieves data of some fields out of many and render on controls on the BioData form. the idea is to make modifications on the display data and update.
Call OpenCon()
Dim comStafffd As SqlCommand = New SqlCommand(sqlstr, cnSUSU)
Dim objReader As SqlDataReader
DAFD2 = New SqlDataAdapter
DAFD2.SelectCommand = comStafffd
DSFD2 = New DataSet
DAFD2.Fill(DSFD2, "tblEmployeeInformation")

objReader = comStafffd.ExecuteReader()

txtSurname.Text = objReader("Surname")
txtFirstname.Text = objReader("Firstname")
txtMiddlename.Text = objReader("Middlename")
txtInitials.Text = objReader("Initials")
txtDay.Text = objReader("DOBDay")
cboMonth.SelectedValue = objReader("DOBMonth")
txtYear.Text = objReader("DOBYear")
txtSex.Text = objReader("Sex")
txtMaritalStatus.Text = objReader("MaritalStatus")
txtBloodgroup.Text = objReader("BloodGrp")
txtGenotype.Text = objReader("Genotype")
txtPlaceofbirth.Text = objReader("PlaceofBirth")
txtHometown.Text = objReader("HomeTown")
txtState.Text = objReader("State")
txtLGA.Text = objReader("LGA")
txtNationality.Text = objReader("Nationality")
txtReligion.Text = objReader("Religion")

If txtSex.Text = "M" Then
optMale.Checked = True
ElseIf txtSex.Text = "F" Then
optFemale.Checked = True
End If

If txtMaritalStatus.Text = "MARRIED" Then
optMarried.Checked = True
ElseIf txtMaritalStatus.Text = "SINGLE" Then
optSingle.Checked = True
ElseIf txtMaritalStatus.Text = "DIVORCED" Then
optDivorced.Checked = True
ElseIf txtMaritalStatus.Text = "WIDOWED" Then
optWidowed.Checked = True
ElseIf txtMaritalStatus.Text = "WIDOWER" Then
optWidower.Checked = True
ElseIf txtMaritalStatus.Text = "SEPERATED" Then
optSeparated.Checked = True
End If

Catch ex As Exception
lblError2.Text = ("Error occurred: " + ex.Message)
End Try
End Sub

I will appreciate if you guys helps me sort out the problem. The displayrecord procedure work when the page loads the first time. At run time the codes do not through exception but only post into tblAuditTrailhuresLive but does not for tblEmployeeInformation. The session tracking is not working properly across the pages. I also suspect "if Not IsPostBack ..." is not used on the page because I am yet to appreciate it. Session is not properly controlled. The logout link/button is not done yet.(Sorry i had to post long post. i would have attached the files rather. Bera with me.)

Post Your Reply Post New Question

 Viewer's Reply
This Question has 0 replies.

Sponsored by
Backup and Recovery Best Practices for Microsoft SQL Server 2005
When Good HTML Goes Bad: How You Can Protect Your Web Applications
Web Application Security — How to Minimize Prevalent Risk of Attacks