Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting

Post new topic   Reply to topic
Problem with displaying ID in database
View previous topic :: View next topic  
Author Message
JohnAndersonUSA
Newbie


Joined: 19 Aug 2005
Posts: 1

PostPosted: Aug 19th, 2005 06:03 AM    Post subject: Problem with displaying ID in database Reply with quote

i have problem displaying radiobutton ID into the database...can u please help mi... i have some code for u to see
' this is my class db module which has the function of creating record

Public Class DBModule
Public Function createRecord(ByVal pobjModule As Modules) As Integer
Dim intNumofRowaffected As Integer
objCmd.CommandText = "INSERT INTO tblModule" & _
"(strNameMO,strAbbreviationMO,strCodeMO,intCoordinatorIdMO)" & _
" VALUES ('" & pobjModule.ModuleName & "', '" & pobjModule.ModuleAbbreviation & "','" & pobjModule.ModuleCode & "', '" & pobjModule.CoordinatorId & "')"
objCn.Open()
intNumofRowaffected = objCmd.ExecuteNonQuery
objCn.Close()
Return intNumofRowaffected
End Function
end class
' this is the codes i used to create record and store in my database
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
btnSelect.Visible = False
End Sub

Private Sub btnSave2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave2.Click, btnBack1.Click
Dim objModule As New Modules
Dim objDBModule As New DBModule
Dim intNumOfRecord As Integer
objModule.ModuleName = txtModuleName.Text.Trim
objModule.ModuleCode = txtModuleCode.Text.Trim
objModule.moduleAbbreviation = txtAbbreviation.Text.Trim
' i believe the error is at the line below..but is just that i cannot able to solve it..
objModule.CoordinatorId=grdLecturer.SelectedItem.ID
intNumOfRecord = objDBModule.createRecord(objModule)
lblMessage.Text = "Saved " & intNumOfRecord & " record."
End Sub
Private Sub btnModuleCoordinator_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnModuleCoordinator.Click
'Dim objArrayList As New ArrayList
'Dim objDBLecturer As New DBLecturer
'Dim objLecturer As New Lecturer
'Dim intLecturerId As Integer = 1
'Dim strHTML As String
'Dim strFullName As String
'objArrayList = objDBLecturer.getLecturerRecords()

'For Each strFullName In objArrayList
' strHTML &= "<input id=""radLecturer"" type=""radio"" name=""intLecturerId"" value = objLecturer.fullName"" /"">"
' intLecturerId &= 1
'Next
Dim objDblecturer As New DBLecturer
Dim objArrayList As New ArrayList

objArrayList = objDblecturer.getLecturerRecords
grdLecturer.DataSource = objArrayList
grdLecturer.DataBind()


grdLecturer.Visible = True
btnSelect.Visible = True


End Sub

Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
Dim strName As String
strName = Request.Form("radLecturer")
txtCoordinator.Text = strName
grdLecturer.Visible = False

End Sub

Private Sub grdLecturer_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdLecturer.ItemDataBound
If e.Item.ItemType <> Web.UI.WebControls.ListItemType.Header And _
e.Item.ItemType <> Web.UI.WebControls.ListItemType.Footer Then
e.Item.Cells(1).Text = "<input type=""Radio"" value=""" & _
e.Item.Cells(2).Text & """name=""radLecturer"" & id=""LecturerId"">"
'e.Item.Cells(0).Text > ""

End If
End Sub
End Class
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » .NET Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic