Re: OleDbDataAdapter.Update and DBase IV

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Miha Markic [MVP C#] (miha)
Date: 03/02/04


Date: Tue, 2 Mar 2004 08:46:35 +0100

Hi mark,

I did mean that @tabletype appears both in set and where part, so you have
two instances of it.
Thus, you have to add it twice to collection.
You should also name them differently: @tabletype for set part and
@original_tabletype for where part.

HTH

-- 
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com
"mark" <mfeferman@houston.rr.com> wrote in message
news:eac0380.0403011829.4de22d47@posting.google.com...
> I'm not sure what you mean by "@TABLETYPE" defined only once...
> I have it defined for each command where it is used(Insert, Update,
Delete).
> Please explain.
>
> BTW, I really appreciate your help.
>
> Sincerely,
> Mark
>
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:<O1U$z85$DHA.1452@TK2MSFTNGP09.phx.gbl>...
> > Hi mark,
> >
> > I think that your problem is that you have @tabletype defined only once,
so
> > the second one is always null.
> > BTW you might avoid changing TABLETYPE as it is unique?
> >
> > -- 
> > Miha Markic [MVP C#] - RightHand .NET consulting & software development
> > miha at rthand com
> > www.rthand.com
> >
> >
> > "mark" <mfeferman@houston.rr.com> wrote in message
> > news:eac0380.0403010654.64706816@posting.google.com...
> > > Hi Miha,
> > > Thanks for the response...I was beginning to worry. <g>
> > >
> > > Anyway, below is my UpdateCommand:
> > >
> > >
> > > daATBD.UpdateCommand = new OleDbCommand("UPDATE ATBD SET
> > > SCHOOLNUM=@SCHOOLNUM, TABLETYPE=@TABLETYPE, TABLEDESC=@TABLEDESC,
> > > CODEHEAD=@CODEHEAD, DESCHEAD=@DESCHEAD, CODELENGTH=@CODELENGTH,
> > > DESCLENGTH=@DESCLENGTH, SECURITY=@SECURITY,
> > > FIELDTYPE=@FIELDTYPE,TABLEGRP=@TABLEGRP WHERE
> > > TABLETYPE=@TABLETYPE",cn);
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@SCHOOLNUM", OleDbType.VarChar));
> > > Param.SourceColumn = "SCHOOLNUM";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@TABLETYPE", OleDbType.VarChar));
> > > Param.SourceColumn = "TABLETYPE";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@TABLEDESC", OleDbType.VarChar));
> > > Param.SourceColumn = "TABLEDESC";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@CODEHEAD", OleDbType.VarChar));
> > > Param.SourceColumn = "CODEHEAD";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@DESCHEAD", OleDbType.VarChar));
> > > Param.SourceColumn = "DESCHEAD";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@CODELENGTH", OleDbType.Numeric));
> > > Param.SourceColumn = "CODELENGTH";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@DESCLENGTH", OleDbType.Numeric));
> > > Param.SourceColumn = "DESCLENGTH";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@SECURITY", OleDbType.VarChar));
> > > Param.SourceColumn = "SECURITY";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@FIELDTYPE", OleDbType.Numeric));
> > > Param.SourceColumn = "FIELDTYPE";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > Param = daATBD.UpdateCommand.Parameters.Add(new
> > > OleDbParameter("@TABLEGRP", OleDbType.VarChar));
> > > Param.SourceColumn = "TABLEGRP";
> > > Param.SourceVersion = DataRowVersion.Original;
> > >
> > > // My work table
> > > DataTable workTable=myDataSet.Tables[MyTable];
> > >
> > > // doing the following actually shows me that I have modified rows...
> > > DataRow[] drs =
> >  workTable.Select(null,null,DataViewRowState.ModifiedCurrent);
> > > for(int i=0;i<foundRows.Length;++i)
> > > {
> > >   DataRow dr=(DataRow)foundRows[i];
> > >   string original=dr["TABLEDESC",DataRowVersion.Original].ToString();
> > >   string current=dr["TABLEDESC",DataRowVersion.Current].ToString();
> > > }
> > >
> > >
> > >
> > >
> > >
> > >
> > > "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> >  news:<Ojp7Mp2$DHA.2808@TK2MSFTNGP10.phx.gbl>...
> > > > Hi mark,
> > > >
> > > > How does your Update commad look like?
> > > > How does your workTable look like?
> > > >
> > > > -- 
> > > > Miha Markic [MVP C#] - RightHand .NET consulting & software
development
> > > > miha at rthand com
> > > > www.rthand.com
> > > >
> > > > "mark" <mfeferman@houston.rr.com> wrote in message
> > > > news:eac0380.0402271334.3fa9618b@posting.google.com...
> > > > > I have written my own DataAdapter for my DBase IV file(s).  The
> > > > > Insert, Update and Delete calls all report success when I call
> > > > > Update(...) on the DataAdapter.  Unfortunately, when I recall the
> > > > > data, only the Inserts and Deletes actually worked.  For some
reason,
> > > > > the UpdateCommand is returning the correct number of records that
were
> > > > > affected according to the Update call:
> > > > >
> > > > >
> > > >
> >
nUpdates=daATBD.Update(workTable.Select(null,null,DataViewRowState.ModifiedC
> > > > urrent));
> > > > >
> > > > > but the changes are just not there...
> > > > >
> > > > > I've tried everything that I can think of, including doing an
combo
> > > > > (Delete/Insert) for every Update, but that isn't going to work
> > > > > either...
> > > > >
> > > > > What gives?
> > > > >
> > > > > Thanks in advance,
> > > > > Mark Feferman
> > > > > mfeferman@houston.rr.com


Relevant Pages

  • Re: OleDbDataAdapter.Update and DBase IV
    ... I'm not sure what you mean by "@TABLETYPE" defined only once... ... I have it defined for each command where it is used. ... BTW, ... > miha at rthand com ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: OleDbDataAdapter.Update and DBase IV
    ... BTW you might avoid changing TABLETYPE as it is unique? ... miha at rthand com ... "mark" wrote in message ... > Param = daATBD.UpdateCommand.Parameters.Add(new ...
    (microsoft.public.dotnet.framework.adonet)