Re: DataRowState.Modified just by navigation?? by William
William
Wed Apr 28 15:13:08 CDT 2004
Ok, something is trying to write to it, and succeeding when the read only
isn't on. (BTW, get rid of that dynamic sql and use parameters...many bad
things come from dynamic sql-trust me on this). I think you posted, but do
all the values in the row change or just a few, if just a few which ones.
What do they change to?
"John Wynstra" <john.wynstra@uni.edu> wrote in message
news:#Nk7MkVLEHA.2704@TK2MSFTNGP10.phx.gbl...
> No new rows are added.
>
> The Issue_Id is set by the calling form. The Issue_ID is used as the
> basis for retreiving the articles from the data source. Here is the
> function from the data class which is called during form_load.
>
> Public Shared Function GetArticles(ByVal issue_id As String) As DataSet
>
> Dim sSQL = "Select article_id, title, page, doc_type,
> summary,issue_id,url FROM Articles where issue_id = '" & issue_id & "'
> Order by page ASC"
> Dim conIXU As OleDbConnection = GetIXUConnection(CONN)
> Dim daArticles As New OleDbDataAdapter(sSQL, conIXU)
> Dim dsArticles As New DataSet()
> daArticles.Fill(dsArticles, "ixu_articles")
> conIXU.Close()
> Return dsArticles
> End Function
>
> When I set the Article_ID(primary key for table) column to read only the
> navigation will not move forward. When I set any of the other columns
> to readonly, the app throws an "Error Number:5 occured. Description:
> Column'TITLE' is read only. Source:System.Data" message whenever I try
> to move forward. So somehow, the simple act of moving to the next row
> is causing a change in the data.
>
> Still baffled.
>
> William Ryan eMVP wrote:
>
> > John:
> >
> > Ok, if it fails then we're dealing with a clean set. Is there a new row
or
> > anything like that?
> >
> > I've seen this once when I tried using a bindingcontext and set a
combobox's
> > databindings and used the bindigncontext for it, but also set the
datasource
> > and valuemember.
> >
> > What is me.Issue_Id? Use a search and find everything hwere you are
> > referencing the datatable...make sure nothing behind the scenes or
something
> > that you meant to comment out is it.
> >
> > Another thing, one by one Set the ReadOnly property of the underlying
> > datacolumn (not the textbox) to true --- if something is changing the
value
> > outside of the ui, readonly on the textbox won't catch it, then you'll
spot
> > it this way. If every column is readonly, then nothing will be able to
be
> > edited, so do it one at a time. Also, don't undo it each time.. First
time
> > set Column[0].ReadOnly = True next set 0 & 1, next 0,1,2. This is
> > redundant, but it will help make things certain that it's not a
calculation
> > or something.
> > "John Wynstra" <john.wynstra@uni.edu> wrote in message
> > news:#C#CmyULEHA.1052@TK2MSFTNGP12.phx.gbl...
> >
> >>William,
> >>
> >>Thanks for taking the time to reply. The Debug.Assert fails.
> >>
> >>I don't have any events associated with these textbox controls.
> >>
> >>If I navigate forward once, and do nothing else, it shows just one row
> >>modified, and if I move forward twice and do nothing, it shows two rows
> >>modified, etc. I do not have anything else going on that I have been
> >>able to put my finger on.
> >>
> >>I am using ms oledb provider to connect to an Oracle database on the
> >>backend. I have wondered if there is some type conversion that is
> >>happening to the data as it is presented in the textbox which actually
> >>changes the data. The fields in the oracle table are mostly varchar,
> >>but two are integer fields.
> >>
> >>By the way, I have also tested setting the "read only" property to true
> >>for each of the text boxes displaying the dataset, and I still get
> >>haschanges(DataRowState.Modified) for each row that I navigate through.
> >>I'm baffled.
> >>
> >>
> >>William Ryan eMVP wrote:
> >>
> >>>John:
> >>>
> >>>Before you make a move anywhere...insert a
> >>>Debug.Assert(Me.dsarticlelist.HasChanges) and see if it fails.
> >>>
> >>>I can't tell from here but do you have any events in your textbox
> >
> > controls
> >
> >>>that chnage the data or anything? If you just navigate forward once,
do
> >>>nothing else, does it show just one row modified for instance? Is
there
> >>>anything else going on?
> >>>"John Wynstra" <john.wynstra@uni.edu> wrote in message
> >>>news:eKmqqnTLEHA.1416@TK2MSFTNGP09.phx.gbl...
> >>>
> >>>
> >>>>I?m running into a problem with a dataset where the columns are bound
to
> >>>>text boxes on a form. By merely navigating through the records using
a
> >>>>bindingmanagerbase, the rowstate for each row that I navigate through
> >>>>changes to modified even though I have not edited the data. What
would
> >>>>cause this? I have included the relevant CODE.
> >>>>
> >>>>
> >>>>'FORM DATASET DECLARED
> >>>>Friend dsarticlelist As New DataSet()
> >>>>Friend issue_id As String
> >>>>Dim bmgrid As BindingManagerBase
> >>>>
> >>>>
> >>>>'LOAD THE FORM, FILL DATASET, BIND TO CONTROLS
> >>>>Private Sub frmArticle_Load(ByVal sender As System.Object, ByVal e As
> >>>>System.EventArgs) Handles MyBase.Load
> >>>>
> >>>> loadarticles(Me.issue_id)
> >>>> Me.BindArticleDataSettofields()
> >>>> bmgrid = BindingContext(Me.dsarticlelist, "ixu_articles")
> >>>> 'Me.loadauthorsubjects(txtArticle_id.Text)
> >>>> End Sub
> >>>>
> >>>> Private Sub loadarticles(ByVal i_id As String)
> >>>> dsarticlelist = ixudata.GetArticles(i_id)
> >>>> End Sub
> >>>>
> >>>>'SET ISSUE_ID THAT IS USED TO GET ARTICLES
> >>>> Public Sub SetIssue_ID(ByVal i_id As String)
> >>>> Me.issue_id = i_id
> >>>> End Sub
> >>>>
> >>>>'BIND DATASET TO CONTROLS
> >>>> Private Sub BindArticleDataSettofields()
> >>>> Me.txtTitle.DataBindings.Add(New Binding("text", _
> >>>> Me.dsarticlelist, "ixu_articles.title"))
> >>>> Me.txtSummary.DataBindings.Add(New Binding("text", _
> >>>> Me.dsarticlelist, "ixu_articles.summary"))
> >>>> Me.txtDoc_Type.DataBindings.Add(New Binding("text", _
> >>>> Me.dsarticlelist, "ixu_articles.doc_type"))
> >>>> Me.txtPage.DataBindings.Add(New Binding("text", _
> >>>> Me.dsarticlelist, "ixu_articles.page"))
> >>>> Me.txturl.DataBindings.Add(New Binding("text", _
> >>>> Me.dsarticlelist, "ixu_articles.url"))
> >>>> Me.txtIssue_id.DataBindings.Add(New Binding("text", _
> >>>> Me.dsarticlelist, "ixu_articles.issue_id"))
> >>>> Me.txtArticle_id.DataBindings.Add(New Binding("text", _
> >>>> Me.dsarticlelist, "ixu_articles.article_id"))
> >>>> End Sub
> >>>>
> >>>>'MOVE FORWARD THROUGH DATASET
> >>>> Private Sub MoveNext()
> >>>> Me.bmgrid.Position += 1
> >>>> End Sub
> >>>>
> >>>>'MOVE BACKWARD THROUGH DATASET
> >>>> Private Sub MovePrevious()
> >>>> Me.bmgrid.Position -= 1
> >>>> End Sub
> >>>>
> >>>>'EVENT THAT TRIGGERS MOVE FORWARD
> >>>> Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e
As
> >>>>System.EventArgs) Handles btnNext.Click
> >>>> Me.MoveNext()
> >>>> End Sub
> >>>>'EVENT THAT TRIGGERS MOVE BACKWARD
> >>>> Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal
> >>>>e As System.EventArgs) Handles btnPrevious.Click
> >>>> Me.MovePrevious()
> >>>> End Sub
> >>>>
> >>>>'DISPLAYs ROWS THAT HAVE BEEN MODIFIED IN A DATAGRID
> >>>> Private Sub btnSave_issue_Click(ByVal sender As System.Object,
> >>>>ByVal e As System.EventArgs) Handles btnSave_issue.Click
> >>>>
> >>>> Try
> >>>> If Me.dsarticlelist.HasChanges Then
> >>>> Dim myds_u_articles As New DataSet()
> >>>> myds_u_articles =
> >>>>Me.dsarticlelist.GetChanges(DataRowState.Modified)
> >>>> Me.dgdchanges.DataSource = myds_u_articles
> >>>>
> >>>> 'If (ixudata.UpdateArticlesinDB(myds_u_articles)) Then
> >>>> 'Me.dsarticlelist.AcceptChanges()
> >>>> 'Else
> >>>> ' Me.dsarticlelist.RejectChanges()
> >>>> 'End If
> >>>> End If
> >>>> Catch
> >>>> UnhandledExceptionHandler()
> >>>>
> >>>> End Try
> >>>> End Sub
> >>>
> >>>
> >>>
> >
> >