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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update existing record trouble (Access DB). Please help.

Status
Not open for further replies.

stfarm

Programmer
May 31, 2001
179
CA
I have an application (Windows App), with several buttons, and functions.
There is one that updates my access DB with some values, works fine, then I have another one where I only need to update 2 values, and it will NOT update the DB.

Maybe I lost my mind, or I will soon. I am sure I am overlooking something simple for the last 2 days.

Please, if you could look at this, or let me know what the easiest way is to Update an existing row, I would really appreciate it.

Thank you for your time.

Steve
 
Forgot the code:

Code:Dim dt As DataTable = DS1.main
Dim dr As DataRow, selectedrows() As DataRow
selectedrows = dt.Select("id=" & CInt(Label3.Text))
For Each dr In selectedrows
ListBox1.Items.Add(dr.Item("itemno"))
Next
dr("status") = "Insane"

OleDb_Punch.Update(DS1)
DS1.AcceptChanges()

Working:

Code:If MessageBox.Show("Are you sure you want to save changes to existing item?", "Confirm Update", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = DialogResult.OK Then
Try

Dim dt As DataTable = DS1.main
Dim dr As DataRow, selectedrows() As DataRow
selectedrows = dt.Select("id=" & CInt(Label3.Text))
' dt.Rows.Find("18")

For Each dr In selectedrows
'ListBox1.Items.Add(dr.Item("itemno"))
Next
' MsgBox(cmb_room.SelectedValue.ToString)
dr("text") = txtpunch2.Text
dr("room") = cmb_room.SelectedValue.ToString
dr("room_desc") = TextBox2.Text
If cmb_problem.Text = "" Then
dr("Problem_type") = ""
dr("Problem_abbr") = ""
Else
dr("Problem_type") = cmb_problem.Text
dr("Problem_abbr") = cmb_problem.SelectedValue.ToString
End If

If cmb_problem.Text = "-- Select Problem Type --" Then
dr("Problem_type") = ""
dr("Problem_abbr") = ""
End If


If cmb_contacts.Text = "" Then
dr("resp") = "Please Select Contact"
dr("resp_abbr") = "Please Select Contact"
Else
dr("resp") = cmb_contacts.Text
dr("resp_abbr") = cmb_contacts.SelectedValue.ToString

End If

If cmb_contacts.Text = "-- Select Contact --" Then
dr("resp") = "Please Select Contact"
dr("resp_abbr") = "Please Select Contact"
End If

dr("status") = cmbStatus.Text
If cmbStatus.Text = "Closed" Then
dr("date_closed") = Now()
End If
If cmbStatus.Text = "Open" Then
dr("date_closed") = System.DBNull.Value
End If
OleDb_Punch.Update(DS1)
DS1.AcceptChanges()
Catch exc As System.Exception
MessageBox.Show("error in FunctionUpdateRecord: " & exc.ToString)
Finally 'clean up
' cmd.Connection.Close()
' cmd.Dispose()
' cmd = Nothing
cmb_room.ResetText()
cmb_problem.ResetText()
cmb_contacts.ResetText()
cmbStatus.ResetText()
cmbStatus.ResetText()

End Try
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top