![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| I've spent hours trying to work out why this is happening, but am at a complete dead-end. In my code behind content page, I check all form elements against the current value. If it's changed, I do some validation and then if it passes, I update the value of the property in the object and add to an arraylist to tell my update function to update this value. If there are any values in this arraylist, it calls an update function in my BLL, passing the object and the fieldlist. Code: If Not fieldlist.Count = 0 Then
If String.IsNullOrEmpty(TaskDetails.page_error) Then
If TaskBLL.SaveTask(TaskDetails, fieldlist, Master.UserDetails.pcuser) Then
update_error.Visible = True
If source = "complete_but" Then
update_error.Text = Master.SiteDetails.correct_box_start("n") & "The task has been completed<br />" & fieldlist.ToString & Master.SiteDetails.box_end
Else
update_error.Text = Master.SiteDetails.correct_box_start("n") & "The task has been updated" & Master.SiteDetails.box_end
End If
ftb_mess.Text = ""
build_notes()
build_userlist()
build_properties()
build_complete()
Master.build_left_menu()
Else
update_error.Visible = True
update_error.Text = Master.SiteDetails.error_box_start("n") & "An error occurred whilst updating the task details<br />" & TaskDetails.page_error & Master.SiteDetails.box_end
End If
Else
update_error.Visible = True
update_error.Text = Master.SiteDetails.error_box_start("n") & "An error occurred whilst updating the task details<br />" & TaskDetails.page_error & Master.SiteDetails.box_end
End If
Else
update_error.Visible = True
update_error.Text = Master.SiteDetails.correct_box_start("n") & "The task details have been updated" & Master.SiteDetails.box_end
End If
DAL Code: Public Shared Function Save(ByVal task As TaskBOL, ByVal fieldlist As ArrayList, ByVal pcuser As Integer) As Boolean
If Not fieldlist.Count = 0 Then
Dim strsql As New StringBuilder
Dim ex_strsql As New StringBuilder
If fieldlist.Contains("visitorref") Then strsql.Append(",visitorref=?visitorref")
If fieldlist.Contains("introref") Then strsql.Append(",introref=?introref")
If fieldlist.Contains("category") Then strsql.Append(",category=?category")
If fieldlist.Contains("title") Then strsql.Append(",title=?title")
If fieldlist.Contains("datedue") Then strsql.Append(",datedue=?datedue")
If fieldlist.Contains("timespent") Then strsql.Append(",timespent=?timespent")
If fieldlist.Contains("complete") Then strsql.Append(",complete='y',completedby=?userref,datecompleted=CURDATE(),filepath=(NULL)")
Dim conn As New MySqlConnection(ConnDAL.connString)
Dim mycommand As New MySqlCommand
Try
ex_strsql.Append("UPDATE user_tasks SET last_updated=NOW(),updatedby=?userref" & strsql.ToString & " WHERE todoref=?todoref;")
'ex_strsql.Append("UPDATE user_tasks_links SET last_viewed=NOW() WHERE todoref=?todoref AND userref=?userref;")
mycommand.Connection = conn
mycommand.CommandText = ex_strsql.ToString
conn.Open()
mycommand.Parameters.AddWithValue("todoref", task.visitorref)
mycommand.Parameters.AddWithValue("userref", pcuser)
If fieldlist.Contains("visitorref") Then mycommand.Parameters.AddWithValue("visitorref", task.visitorref)
If fieldlist.Contains("introref") Then mycommand.Parameters.AddWithValue("introref", task.introref)
If fieldlist.Contains("category") Then mycommand.Parameters.AddWithValue("category", task.category)
If fieldlist.Contains("title") Then mycommand.Parameters.AddWithValue("title", task.title)
If fieldlist.Contains("datedue") Then
If Not IsNothing(task.datedue) Then
mycommand.Parameters.AddWithValue("datedue", Format(task.datedue, "yyyy/MM/dd"))
Else
mycommand.Parameters.AddWithValue("datedue", DBNull.Value)
End If
End If
If fieldlist.Contains("timespent") Then mycommand.Parameters.AddWithValue("timespent", task.timespent)
mycommand.ExecuteNonQuery()
Catch ex As MySqlException
task.page_error = ex.Message.ToString
Finally
mycommand.Dispose()
conn.Close()
conn.Dispose()
End Try
If String.IsNullOrEmpty(task.page_error) Then
Return True
Else
Return False
End If
end function
I've debugged the code passing values to the screen and as far as I can tell, it runs with no problems. I get no errors, but the details don't update. I use the same syntax in other functions and they work fine. I'm just at a complete loss as to why this won't work. Does anyone have any idea what the problem might be? Thanks |
| Sponsored Links |
|
#2
| ||||
| ||||
| I can't believe it. I've spent literally hours looking through this code and have just spotted my mistake. I set the parameter of the table key for updating to the wrong property of the object. Just couldn't see the wood for the trees. Sorry guys.... |
|
#3
| ||||
| ||||
| Start by putting a breakpoint on Public Shared Function Save and then press F5. Run the page and try saving. The debugger will popup in Visual Studio. step through each line and view the values for each property. See if they have even changed.
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.Join our Folding team: DeveloperBarn Folding |
|
#4
| ||||
| ||||
| Quote:
|
| The Following User Says Thank You to jmurrayhead For This Useful Post: | ||
richyrich (June 3rd, 2008) | ||
|
#5
| ||||
| ||||
| Yup, the best I've found for locating an error is to post a question on the boards -- you'll spot in minutes after you hit save.
__________________ Wolffy ------------------------ Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. |
| The Following User Says Thank You to Wolffy For This Useful Post: | ||
richyrich (June 3rd, 2008) | ||
|
#6
| ||||
| ||||
| Quote:
|
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Store Calculated Values (Updating Fields) | sbenj69 | Microsoft Access | 6 | May 26th, 2008 10:18 AM |
| Help with Updating field | Rebelle | Microsoft Access | 5 | April 1st, 2008 06:45 PM |