Maven4Champ
Technical User
- Jun 16, 2004
- 154
Posting code below. Working in our Dev environment on one single table
table: ResponsibilityMaster
ID (pk)
ResponsibilityName
ResponsibilityDesc
LDTSyntax
My goal and intent is to display a drop-down of ResponsibilityName and on change of ResponsibilityName, load the LDTSyntax in the textarea below. The user then hits "Edit Syntax" (Button3) which sets the textarea (TextBox1) to Enabled = True to allow for editing. The user then makes their changes manually or pasts from clipboard (Button2). They would then hit the "Commit Changes" button (Button4) which would complete the edit and update the SQL Server table with the changes they have made.
Here is the problem: Everything works in the application except the most crucial piece (of course) - it's when the user hits the Commit Changes button, the record updates visually in the form but when closing out of the form and going back in OR by querying the db, nothing actually changed. So from there, it leads me to believe I am still only updating the dataset in my form and not actually truly passing those changes to the db.
Code is below:
Any advice on how to do the updates to the table with datasets and tableadapters is GREALTY appreciated. I was working on this from start to finish for about 10 hours yesterday and got hung up on the table update for about 3 of those hours, still with no resolution. I look forward to any advice and recommendations.
table: ResponsibilityMaster
ID (pk)
ResponsibilityName
ResponsibilityDesc
LDTSyntax
My goal and intent is to display a drop-down of ResponsibilityName and on change of ResponsibilityName, load the LDTSyntax in the textarea below. The user then hits "Edit Syntax" (Button3) which sets the textarea (TextBox1) to Enabled = True to allow for editing. The user then makes their changes manually or pasts from clipboard (Button2). They would then hit the "Commit Changes" button (Button4) which would complete the edit and update the SQL Server table with the changes they have made.
Here is the problem: Everything works in the application except the most crucial piece (of course) - it's when the user hits the Commit Changes button, the record updates visually in the form but when closing out of the form and going back in OR by querying the db, nothing actually changed. So from there, it leads me to believe I am still only updating the dataset in my form and not actually truly passing those changes to the db.
Code is below:
Code:
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Data.SqlClient
Public Class LDTUpdate
Private Sub LDTUpdate_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'TechWebsiteDataSet.ResponsibilityMaster' table. You can move, or remove it, as needed.
Me.ResponsibilityMasterTableAdapter.Fill(Me.TechWebsiteDataSet.ResponsibilityMaster)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FrmLDT.Show()
Me.Hide()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim pasteResponse As Integer
pasteResponse = MsgBox("Are you sure you want to paste from the clipboard? This cannot be undone.", MsgBoxStyle.YesNo, "LDT Update Confirmation")
If pasteResponse = vbYes And Me.TextBox1.Enabled = True Then
Me.TextBox1.Text = Clipboard.GetText()
ElseIf pasteResponse = vbYes And Me.TextBox1.Enabled = False Then
MsgBox("You cannot paste text into the text area when disabled. Please choose Edit LDT Syntax before pasting.", MsgBoxStyle.OkOnly, "Past Clipboard Error")
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.TextBox1.Enabled = True
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.TextBox1.Enabled = False
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'Dim tmpSyntax As String = TextBox1.Text
Dim rowID As Integer = CInt(TextBox2.Text)
Dim LDTRow() As Data.DataRow = TechWebsiteDataSet.Tables("ResponsibilityMaster").Select("ID = '" & rowID & "'")
LDTRow(0)("LDTSyntax") = Me.TextBox1.Text
Me.ResponsibilityMasterBindingSource.EndEdit()
Me.ResponsibilityMasterTableAdapter.Update(LDTRow(0))
MsgBox("LDT Syntax has been updated!", MsgBoxStyle.OkOnly, "Commit Success!")
End Sub
End Class
Any advice on how to do the updates to the table with datasets and tableadapters is GREALTY appreciated. I was working on this from start to finish for about 10 hours yesterday and got hung up on the table update for about 3 of those hours, still with no resolution. I look forward to any advice and recommendations.