Re: BindingSource.EndEdit - Not updating underlying data source
- From: Dustin Davis <dustin@xxxxxxxxxxxxxxxx>
- Date: Thu, 04 Jan 2007 10:04:23 -0700
There are active x controls involved so I don't think you can just paste this in to VS. For what it is worth, here is all the code to this form. I'm open to criticism on any of it:
Public Class frmZones
#Region "Class Variables"
Friend ProcessID As Integer
Private drvZone As DataRowView
Private drZone As dsZones.zonesRow
Private TemplateFile As String
Private dsIndexFields As DataSet
Private bmZones As BindingManagerBase
' Button text for adding & editing barcode zones
Const SaveButtonText As String = "Save Zone"
Const NewButtonText As String = "New Zone"
Const EditButtonText As String = "Edit Zone"
Const CancelButtonText As String = "Cancel"
#End Region
#Region "Form Events"
Public Sub New(ByVal ProcessID As Integer)
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.ProcessID = ProcessID
End Sub
Private Sub frmZones_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Set list box to owner drawn type
Me.lstZones.DrawMode = DrawMode.OwnerDrawFixed
AddHandler Me.lstZones.DrawItem, AddressOf Me.lstZones_DrawItem
' Fill Zones Table Adapter
Try
frmMain.DbConnect()
Me.ZonesTableAdapter.Connection = frmMain.Cnn
Me.ZonesTableAdapter.Fill(Me.DsZones.zones, ProcessID)
Me.ZonesBindingSource.DataSource = Me.DsZones
Me.bmZones = Me.BindingContext(DsZones, "zones")
Catch ex As Exception
MsgBox(ex.Message)
End Try
' Form settings
Me.Text = Application.ProductName & ": " & Me.Text
Me.WindowState = FormWindowState.Maximized
' Initialize Scanner
Me.IkScan1.ScanInitialize(Handle.ToInt32, 1, 0, "1.0", "Microfilm Service Corp", "Barcode Ripper", "Barcode Ripper")
' Set display rectangle colors
With Me.IkDisp1
.RectColor1 = Color.Red
.RectColor2 = Color.LightBlue
End With
' Load KF fields
dsIndexFields = frmMain.GetIndexFields(ProcessID)
If Not Me.dsIndexFields Is Nothing Then
Dim dr As DataRow
dr = Me.dsIndexFields.Tables("ProjectDef").NewRow()
dr.Item("fieldnum") = 0
dr.Item("displayname") = "(No Associated Field)"
Me.dsIndexFields.Tables("ProjectDef").Rows.InsertAt(dr, 0)
With Me.cboKfField
.DataSource = Me.dsIndexFields.Tables("ProjectDef")
.ValueMember = "fieldnum"
.DisplayMember = "displayname"
End With
Else
Dim kfc As New Collection
kfc.Add("N/A", 0)
Me.cboKfField.DataBindings.Clear()
Me.cboKfField.DataSource = kfc
Me.cboKfField.SelectedItem = 0
End If
Me.lstZones_SelectedIndexChanged(sender, e)
EnableZoneFields(False)
' Tool tips
ToolTip1.SetToolTip(Me.btnSaveTemplate, "This will save the currenlty loaded image for this process")
' Load template
TemplateFile = IO.Path.Combine(Application.StartupPath, "Templates\" & Me.ProcessID & ".tif")
If IO.File.Exists(TemplateFile) Then
Me.LoadImage(TemplateFile)
End If
Me.ZonesTableAdapter.Update(Me.DsZones)
End Sub
Private Sub frmZones_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.IkScan1.ScanTerminate()
frmMain.DbDisconnect()
End Sub
#End Region
#Region "Owner-drawn List Box"
Private Sub lstZones_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs)
Dim Color As Brush = Brushes.White
' The following method should generally be called before drawing.
' It is actually superfluous here, since the subsequent drawing
' will completely cover the area of interest.
e.DrawBackground()
'The system provides the context
'into which the owner custom-draws the required graphics.
'The context into which to draw is e.graphics.
'The index of the item to be painted is e.Index.
'The painting should be done into the area described by e.Bounds.
If e.Index >= 0 Then
Try
If e.Index < DsZones.Tables(0).Rows.Count AndAlso DsZones.Tables(0).Rows(e.Index).RowState <> DataRowState.Deleted Then
If e.BackColor.ToString.Contains("Highlight") Then
If Not IsDBNull(DsZones.Tables(0).Rows(e.Index).Item("split_zone")) AndAlso DsZones.Tables(0).Rows(e.Index).Item("split_zone") Then
Color = Brushes.DarkRed
Else
Color = Brushes.Black
End If
Else
If Not IsDBNull(DsZones.Tables(0).Rows(e.Index).Item("split_zone")) AndAlso DsZones.Tables(0).Rows(e.Index).Item("split_zone") Then
Color = Brushes.Yellow
Else
Color = Brushes.White
End If
End If
e.Graphics.DrawString(DsZones.Tables(0).Rows(e.Index).Item("name").ToString, lstZones.Font, Color, e.Bounds.X, e.Bounds.Y)
End If
Catch ex As Exception
MsgBox(ex.Message & vbNewLine & e.Index.ToString, MsgBoxStyle.Information)
End Try
End If
e.DrawFocusRectangle()
End Sub
#End Region
#Region "Template Buttons"
Private Sub btnSaveTemplate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveTemplate.Click
If Me.IkDisp1.ImgHandle Then
If Not IO.Directory.Exists(IO.Path.GetDirectoryName(TemplateFile)) Then
Try
IO.Directory.CreateDirectory(IO.Path.GetDirectoryName(TemplateFile))
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
Exit Sub
End Try
End If
Me.IkFile1.ImgHandle = Me.IkDisp1.ImgHandle
Me.IkFile1.LoadFile(IMGKIT6Lib.LoadFileConstants.ikLoad)
Me.IkFile1.FileName = TemplateFile
Me.IkFile1.SaveFile(IMGKIT6Lib.SaveFileConstants.ikSaveTIFFNoncompressed)
End If
End Sub
Private Sub btnDeleteTemplate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDeleteTemplate.Click
Dim DeleteTemplate As New dlgDeleteTemplate
If DeleteTemplate.ShowDialog = Windows.Forms.DialogResult.OK Then
' Delete the template image
If IO.File.Exists(TemplateFile) Then
Try
IO.File.Delete(TemplateFile)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
Exit Sub
End Try
End If
Me.IkDisp1.Display(IMGKIT6Lib.DispModeConstants.ikClear)
Me.IkDisp1.Refresh()
If DeleteTemplate.DeleteZones Then
While Me.ZonesBindingSource.Count > 0
Me.ZonesBindingSource.RemoveCurrent()
Me.ZonesTableAdapter.Update(Me.DsZones)
End While
End If
End If
End Sub
Private Sub btnReloadTemplate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReloadTemplate.Click
If IO.File.Exists(TemplateFile) Then
Me.LoadImage(TemplateFile)
Else
MsgBox("A saved template image does not exist for this process.", MsgBoxStyle.Information)
End If
End Sub
#End Region
#Region "Image Buttons & Scanning"
Private Sub btnLoadImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadImage.Click
Me.IkFile1.FilePath = My.Computer.FileSystem.SpecialDirectories.MyDocuments
If Me.IkFile1.OpenFileDlg() Then
Me.LoadImage(Me.IkFile1.FileName)
End If
End Sub
Private Sub btnScanImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScanImage.Click
Dim Ret As Boolean
Dim Index(10) As Integer
Try
Me.IkScan1.UiMode = IMGKIT6Lib.ScanUIModeConstants.ikScanUICLOSE
Ret = IkScan1.ScanExec(Index(0))
IkScan1.ScanTerminate()
Catch ex As Exception
MsgBox("Error scanning document: " & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Private Sub btnSelectScanner_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectScanner.Click
Me.IkScan1.ScanSelect()
End Sub
Private Sub btnScanSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnScanSettings.Click
End Sub
Private Sub IkScan1_AfterScan(ByVal sender As Object, ByVal e As AxIMGKIT6Lib._IIkScanEvents_AfterScanEvent) Handles IkScan1.AfterScan
Dim Filename As String
Me.IkFile1.ImgHandle = e.dibHandle
Me.IkCommon1.ImgHandle = IkFile1.ImgHandle
Me.IkCommon1.GetImageType()
Filename = "scan.tif"
IkFile1.FileName = IO.Path.Combine(IO.Path.GetTempPath, Filename)
If Not IkFile1.SaveFile(IMGKIT6Lib.SaveFileConstants.ikSaveTIFFNoncompressed) Then
MsgBox("Could not save scanned file...")
End If
Me.IkFile1.LoadFile(IMGKIT6Lib.LoadFileConstants.ikLoad)
Me.IkCommon1.ImgHandle = Me.IkFile1.ImgHandle
Me.IkCommon1.GetImageType()
With Me.IkDisp1
.ImgHandle = Me.IkFile1.ImgHandle
.Display(IMGKIT6Lib.DispModeConstants.ikScale)
.ScrollBar = True
.ScrollDir = IMGKIT6Lib.ScrollDirConstants.ikBottomRight
.ScrollDrag = False
.RectDraw = True
End With
End Sub
#End Region
#Region "Image Display"
Private Sub IkDisp1_MouseUpImage(ByVal sender As Object, ByVal e As AxIMGKIT6Lib._IIkDispEvents_MouseUpImageEvent) Handles IkDisp1.MouseUpImage
If Me.txtZoneName.Enabled Then
With Me.IkDisp1
Me.txtTop.Text = .RectTop
Me.txtLeft.Text = .RectLeft
Me.txtBottom.Text = .RectBottom
Me.txtRight.Text = .RectRight
End With
' Give each text box focus or else it won't save changes
With Me
.txtTop.Focus()
.txtLeft.Focus()
.txtBottom.Focus()
.txtRight.Focus()
End With
Else
Try
With Me.IkDisp1
.RectTop = Me.txtTop.Text
.RectLeft = Me.txtLeft.Text
.RectBottom = Me.txtBottom.Text
.RectRight = Me.txtRight.Text
End With
Catch ex As Exception
End Try
End If
End Sub
Private Function LoadImage(ByVal FileName As String) As Boolean
Try
Me.IkFile1.FileName = FileName
Me.IkFile1.LoadFile(IMGKIT6Lib.LoadFileConstants.ikLoad)
Me.IkCommon1.ImgHandle = Me.IkFile1.ImgHandle
Me.IkCommon1.GetImageType()
With Me.IkDisp1
.ImgHandle = Me.IkFile1.ImgHandle
.Display(IMGKIT6Lib.DispModeConstants.ikScale)
.ScrollBar = True
.ScrollDir = IMGKIT6Lib.ScrollDirConstants.ikBottomRight
.ScrollDrag = False
.RectDraw = True
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
Return False
End Try
' Set the first box
IkDisp1_MouseUpImage(Nothing, Nothing)
Return True
End Function
#End Region
#Region "Coordinate Changes"
Private Sub txtTop_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTop.TextChanged
Me.ChangeCoordinate(Me.IkDisp1.RectTop, Me.txtTop)
End Sub
Private Sub txtLeft_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtLeft.TextChanged
Me.ChangeCoordinate(Me.IkDisp1.RectLeft, Me.txtLeft)
End Sub
Private Sub txtBottom_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBottom.TextChanged
Me.ChangeCoordinate(Me.IkDisp1.RectBottom, Me.txtBottom)
End Sub
Private Sub txtRight_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtRight.TextChanged
Me.ChangeCoordinate(Me.IkDisp1.RectRight, Me.txtRight)
End Sub
Private Sub ChangeCoordinate(ByRef IkCoord As Integer, ByRef TextBox As Windows.Forms.TextBox)
Try
IkCoord = TextBox.Text
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
#End Region
#Region "Zones Buttons & Fields"
Private Sub btnNewSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewSave.Click
If Me.btnNewSave.Text = frmZones.SaveButtonText Then
If Not IsNumeric(Me.txtTop.Text) OrElse Not IsNumeric(Me.txtLeft.Text) OrElse Not IsNumeric(Me.txtBottom.Text) OrElse Not IsNumeric(Me.txtRight.Text) Then
MsgBox("Coordinates are missing or invalid. Please select highlight the barcode zone, or enter numeric coordinates manually.", MsgBoxStyle.Information)
Exit Sub
ElseIf txtZoneName.Text.Length = 0 Then
MsgBox("You must give this zone a name before saving it.", MsgBoxStyle.Information)
Me.txtZoneName.Focus()
Exit Sub
Else
Try
If Not drvZone Is Nothing Then
Me.DsZones.zones.Rows.Add(drvZone.Row)
Me.ZonesBindingSource.CancelEdit()
Else
Me.ZonesBindingSource.EndEdit()
End If
Me.ZonesTableAdapter.Update(Me.DsZones.zones)
Me.DsZones.AcceptChanges()
' Debug purposes
' Me.ZonesTableAdapter.Fill(DsZones.zones, ProcessID)
Catch ex As Exception
MsgBox("Error Saving Changes: " & ex.Message, MsgBoxStyle.Critical)
End Try
End If
Me.EnableZoneFields(False)
Else
Try
Me.drvZone = Me.ZonesBindingSource.AddNew()
drvZone.Item("processes_id") = ProcessID
drvZone.Item("split_zone") = 0
drvZone.Item("kf_field_id") = 0
Me.EnableZoneFields()
Catch ex As Exception
MsgBox("Error adding new zone: " & ex.Message, MsgBoxStyle.Exclamation)
End Try
End If
End Sub
Private Sub btnEditCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditCancel.Click
If Me.btnEditCancel.Text = frmZones.EditButtonText Then
Me.EnableZoneFields()
Else
Me.EnableZoneFields(False)
Me.ZonesBindingSource.CancelEdit()
End If
Me.drvZone = Nothing
End Sub
Private Sub lstZones_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstZones.SelectedIndexChanged
If Me.lstZones.SelectedIndex >= 0 And Me.lstZones.SelectedIndex < bmZones.Count Then
bmZones.Position = Me.lstZones.SelectedIndex
End If
'If Me.lstZones.SelectedIndex >= 0 Then
' Try
' Me.txtTop.Text = CType(Me.ZonesBindingSource.Item(Me.lstZones.SelectedIndex), DataRowView).Item("top").ToString
' Me.txtLeft.Text = CType(Me.ZonesBindingSource.Item(Me.lstZones.SelectedIndex), DataRowView).Item("left").ToString
' Me.txtBottom.Text = CType(Me.ZonesBindingSource.Item(Me.lstZones.SelectedIndex), DataRowView).Item("bottom").ToString
' Me.txtRight.Text = CType(Me.ZonesBindingSource.Item(Me.lstZones.SelectedIndex), DataRowView).Item("right").ToString
' Me.txtZoneName.Text = CType(Me.ZonesBindingSource.Item(Me.lstZones.SelectedIndex), DataRowView).Item("name").ToString
' If IsDBNull(CType(Me.ZonesBindingSource.Item(Me.lstZones.SelectedIndex), DataRowView).Item("kf_field_id")) Then
' Me.cboKfField.Text = "N/A"
' Else
' Me.cboKfField.SelectedValue = CType(Me.ZonesBindingSource.Item(Me.lstZones.SelectedIndex), DataRowView).Item("kf_field_id")
' End If
' Catch ex As Exception
' MsgBox("Error updating fields: " & ex.Message, MsgBoxStyle.Exclamation)
' End Try
'End If
End Sub
Private Sub EnableZoneFields(Optional ByVal Enable As Boolean = True)
Try
Me.btnEditCancel.Enabled = True
Me.lstZones.Enabled = Not Enable
Me.txtTop.Enabled = Enable
Me.txtLeft.Enabled = Enable
Me.txtBottom.Enabled = Enable
Me.txtRight.Enabled = Enable
Me.txtZoneName.Enabled = Enable
If Me.dsIndexFields Is Nothing Then
Me.cboKfField.Enabled = False
Else
Me.cboKfField.Enabled = Enable
End If
If Enable Then
Me.btnNewSave.Text = frmZones.SaveButtonText
Me.btnEditCancel.Text = frmZones.CancelButtonText
Else
Me.btnNewSave.Text = frmZones.NewButtonText
Me.btnEditCancel.Text = frmZones.EditButtonText
' If an existing zone is not selected then we can't edit it
If Me.lstZones.Items.Count = 0 Then
Me.btnEditCancel.Enabled = False
End If
End If
Catch ex As Exception
MsgBox("Error enabling fields: " & ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
#End Region
#Region "Right-click Menu Actions"
Private Sub Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delete.Click
If MsgBox("Are you sure you want to delete the selected zone?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Try
Me.ZonesBindingSource.RemoveCurrent()
Me.ZonesTableAdapter.Update(Me.DsZones)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
End If
End Sub
Private Sub TestZoneToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TestZoneToolStripMenuItem.Click
Dim Barcode As SoftekBarcode
Dim nBarCode As Short
Dim strBarcode As String
Barcode = New SoftekBarcode()
frmMain.SetBCPrefs(Me.ProcessID, Barcode)
' Set area to scan
Barcode.SetScanRect(Me.txtLeft.Text, Me.txtTop.Text, Me.txtRight.Text, Me.txtBottom.Text, 0)
nBarCode = Barcode.ScanBarCode(Me.IkFile1.FileName)
' Or read the barcode from an image in a PictureBox
' bm = New Bitmap(Me.PictureBox1.Image)
' nBarCode = barcode.ScanBarCodeFromBitmap(bm.GetHbitmap())
If (nBarCode < 0) Then
MsgBox("Error reading barcode")
ElseIf (nBarCode = 0) Then
MsgBox("No barcode found on this image")
Else
strBarcode = Barcode.GetBarString(1)
MsgBox("Barcode Found: " & strBarcode)
End If
End Sub
Private Sub SplitMultipageTIFsWithThisZoneToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SplitMultipageTIFsWithThisZoneToolStripMenuItem.Click
For i As Integer = 0 To DsZones.Tables(0).Rows.Count - 1
Me.drvZone = Me.ZonesBindingSource.Item(i)
If i = Me.lstZones.SelectedIndex Then
drvZone.Item("split_zone") = 1
Else
drvZone.Item("split_zone") = 0
End If
Next
Try
Me.ZonesBindingSource.EndEdit()
Me.ZonesTableAdapter.Update(Me.DsZones)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
Me.lstZones.Refresh()
End Sub
#End Region
End Class
RobinS wrote:
Addnew adds the row to the dataset; CancelEdit will cancel any changes.
made, so I wouldn't use that, even if it accidentally fixes your problem.
If you use that repeatedly just because you can't get your stuff to
work, you will pay the price down the road.
If you repost the whole thing (but without the > in front), I'll paste
it into VS and figure out how to fix it.
If you tell me what you're trying to do, I'll post some code that shows
you how to do that.
I suspect you have a form that is bound to your strongly typed dataset
and you are trying to figure out how to add the row to the dataset.
Robin S.
------------------------------
"Dustin Davis" <dustin@xxxxxxxxxxxxxxxx> wrote in message news:%23s0YYKBMHHA.3424@xxxxxxxxxxxxxxxxxxxxxxxWhat is bmZones?bmZones is a BindingManagerBase that I tried and couldn't get to work either.
What is this about?My SQL statement to fill the dataset contains "WHERE process_id = @process_id" so I have to pass in a process id
Me.ZonesTableAdapter.Fill(Me.DsZones.Zones, ProcessID)
When I used strongly typed dataset, the Fill only takes one argument.
Do you have Option Strict on?Nope
I don't understand the use of the BIndingContext. Are you usingVS2005
.Net 1.1 and VS2003, or .Net 2.0 and VS2005?
I think I may have found a suitable solution that is not so kludgy.
When I'm adding, before the update I call:
Me.DsZones.zones.Rows.Add(drvZone.Row)Then call the Update method. This seems to work for me.
Me.ZonesBindingSource.CancelEdit()
Thanks for all your help!
Robin S.
----------------------
"Dustin Davis" <dustin@xxxxxxxxxxxxxxxx> wrote in message news:%232HzqK2LHHA.320@xxxxxxxxxxxxxxxxxxxxxxxme.drvZone is a datarowviewPrivate drvZone As DataRowViewI fill the table adapter on form load' Fill Zones Table AdapterHere is the routine that basically does everything that is not working. The else portion adds the new row, while the if portion should end the edit and update the database.
Try
frmMain.DbConnect()
Me.ZonesTableAdapter.Connection = frmMain.Cnn
Me.ZonesTableAdapter.Fill(Me.DsZones.zones, ProcessID)
Me.ZonesBindingSource.DataSource = Me.DsZones
Me.bmZones = Me.BindingContext(DsZones, "zones")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Private Sub btnNewSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNewSave.Click
If Me.btnNewSave.Text = frmZones.SaveButtonText Then
If Not IsNumeric(Me.txtTop.Text) OrElse Not IsNumeric(Me.txtLeft.Text) OrElse Not IsNumeric(Me.txtBottom.Text) OrElse Not IsNumeric(Me.txtRight.Text) Then
MsgBox("Coordinates are missing or invalid. Please select highlight the barcode zone, or enter numeric coordinates manually.", MsgBoxStyle.Information)
Exit Sub
ElseIf txtZoneName.Text.Length = 0 Then
MsgBox("You must give this zone a name before saving it.", MsgBoxStyle.Information)
Me.txtZoneName.Focus()
Exit Sub
Else
Try
' Not sure why, but the following two lines resolve a bug of not saving the data...
'Me.ZonesBindingSource.AddNew()
'Me.ZonesBindingSource.CancelEdit()
Me.ZonesBindingSource.EndEdit()
Me.ZonesTableAdapter.Update(Me.DsZones)
Catch ex As Exception
MsgBox("Error Saving Changes: " & ex.Message, MsgBoxStyle.Critical)
End Try
End If
Me.EnableZoneFields(False)
Else
Try
Me.drvZone = Me.ZonesBindingSource.AddNew()
drvZone.Item("processes_id") = ProcessID
drvZone.Item("split_zone") = 0
drvZone.Item("kf_field_id") = 0
Me.EnableZoneFields()
Catch ex As Exception
MsgBox("Error adding new zone: " & ex.Message, MsgBoxStyle.Exclamation)
End Try
End If
End Sub
RobinS wrote:What is me.drvZone? What are you binding the dataset to? Can you post some more code?
Robin S.
-----------------------------
"Dustin Davis" <dustin@xxxxxxxxxxxxxxxx> wrote in message news:O46bv0zLHHA.2236@xxxxxxxxxxxxxxxxxxxxxxxThat's a kludge, and I wouldn't do it just because it works.Right, I was just hoping it might help someone help me :)
Can you check the RowState of the new record and see ifBefore and after I call the EndEdit, the RowState says "Detached{1}"
it is, indeed, set as an Insert and not an Update?
Is this a clue?
Is dsZones a strongly typed dataset that you designedYes it is.
with the DataSet Designer?
Is the ZonesTableAdapter one that you set up, or did itIt came from the DataSet Designer, I think...
come from the DataSet Designer, too?
Does it actuallyYes, I believe so.
have the update logic for Inserting records built in?
If you change the values in a row and call Update on theUm, that's another problem I haven't figured out yet. I'm doing this elsewhere and I tend to get this error often:
table adapter, do they get updated?
Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.
Is the primary key of the table included in the dataset?Yes it is.
Robin S.
- Follow-Ups:
- References:
- BindingSource.EndEdit - Not updating underlying data source
- From: Dustin Davis
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: Earl
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: Dustin Davis
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: Dustin Davis
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: RobinS
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: Dustin Davis
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: RobinS
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: Dustin Davis
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: RobinS
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: Dustin Davis
- Re: BindingSource.EndEdit - Not updating underlying data source
- From: RobinS
- BindingSource.EndEdit - Not updating underlying data source
- Prev by Date: Re: Concurrency Violation
- Next by Date: Re: Copy a database table into another using ado.net
- Previous by thread: Re: BindingSource.EndEdit - Not updating underlying data source
- Next by thread: Re: BindingSource.EndEdit - Not updating underlying data source
- Index(es):
Loading