updating the table from the list view columns
I have written a program, which in response to user input, populates the data in a list view (msaccess table) Now I need to extract the data from list view and update a different table. Updating the table is not working. Can some one help this ignorent ?
Here is the code
Dim mySearchString As String
Dim SearchName As String
SearchName = txtMovieID.Text
if txtPerson.Text = "" then
MessageBox.Show("Please First select the perosn who is renting movies")
Else
If Not IsNumeric(SearchName) Then
MessageBox.Show(" Plese type The movie Name Correctly", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Hand)
Else
mySearchString = "Select Number,Title,DaysToRent,RentalRate, Status from tblInventory where number=" & txtMovieID.Text
DsRental2.Clear()
daRental.SelectCommand.CommandText = mySearchString
daRental.Fill(DsRental2)
If DsRental2.tblInventory.Count = 0 Then
MessageBox.Show(" Movie by " & SearchName & " doesnot exist", "Search Result")
Else
Try
With lvwRental
Dim Item As ListViewItem
Item = New ListViewItem(txtMovieID.Text)
Item.SubItems.Add(DsRental2.tblInventory(0).Title)
Item.SubItems.Add(Today)
Item.SubItems.Add(Today.AddDays(txtDaysToRent.Text ))
Item.SubItems.Add(FormatCurrency(txtRentalRate.Tex t))
Item.SubItems.Add(FormatCurrency(txtRentalRate.Tex t))
lvwRental.Items.Add(Item)
txtMovieID.Clear()
End With
Catch except As Exception
MessageBox.Show(except.Message, except.GetType.ToString())
End Try
End If
End If
End If
Dim newRow As dsTransection.tblRentalRow
Dim Item As ListViewItem
Dim result As String
Try
newRow = DsTransection1.tblRental.NewRow()
newRow("CustomerID") = txtCustID.Text
newRow("MovieID") = lvwRental.Columns(Val("MovieID"))
newRow("DateRented") = Today
newRow("Datedue") = lvwRental.Columns("DateDue")
result = (MessageBox.Show("Do You Want to record transection Now", "", MessageBoxButtons.YesNo, MessageBoxIcon.Stop))
If result = DialogResult.Yes Then
DsTransection1.tblRental.Rows.Add(newRow)
daTransection.Update(DsTransection1)
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
newRow.CancelEdit()
End Try
yvk
__________________
yvk
|