PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET How to Fill a ADO RecordSet into DataSet with Changing state?

Reply

How to Fill a ADO RecordSet into DataSet with Changing state?

 
Thread Tools Rate Thread
Old 16-03-2004, 12:16 PM   #1
=?Utf-8?B?WGlhUw==?=
Guest
 
Posts: n/a
Default How to Fill a ADO RecordSet into DataSet with Changing state?


Hello
The problem is that when the RecordSet is in changing ,after oda.fill,the All rows int DataSet.tables[0] will lose changing state

for example,there a ADOr.xml file
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882
xmlns:rs='urn:schemas-microsoft-com:rowset
xmlns:z='#RowsetSchema'><s:Schema id='RowsetSchema'><s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30
rs:updatable='true'><s:AttributeType name='CODE_NAME' rs:number='1' rs:writeunknown='true
rs:basecatalog='YSWebTest' rs:basetable='T_CODE_MEAN
rs:basecolumn='CODE_NAME' rs:keycolumn='true'><s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='40
rs:maybenull='false'/></s:AttributeType><s:AttributeType name='CODE_DESC' rs:number='2' rs:nullable='true
rs:writeunknown='true' rs:basecatalog='YSWebTest' rs:basetable='T_CODE_MEAN
rs:basecolumn='CODE_DESC'><s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='80'/></s:AttributeType><s:AttributeType name='CANMODIFY' rs:number='3' rs:nullable='true
rs:writeunknown='true' rs:basecatalog='YSWebTest' rs:basetable='T_CODE_MEAN
rs:basecolumn='CANMODIFY'><s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='1'/></s:AttributeType><s:AttributeType name='REMARKS' rs:number='4' rs:nullable='true
rs:writeunknown='true' rs:basecatalog='YSWebTest' rs:basetable='T_CODE_MEAN
rs:basecolumn='REMARKS'><s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='1000'/></s:AttributeType><s:extends type='rs:rowbase'/></s:ElementType></s:Schema><rs:data><z:row CODE_NAME='9' CODE_DESC='9' CANMODIFY='9' REMARKS='9'/><rs:insert><z:row CODE_NAME='8' CODE_DESC='8' CANMODIFY='8' REMARKS='8'/></rs:insert></rs:data></xml

in this XML Data ,there a new row in insert state (rs:insert)
then ,i read xml into a new ADO RecoredSet and fill into then DataSet ,like this code
OleDbDataAdapter oda = new OleDbDataAdapter ()
ADODB.Recordset adoRS = new ADODB.Recordset()
DataSet ds2 = new DataSet()
adoRS.Open(@"d:\ADOr.xml","Provider=MSPersist;",CursorTypeEnum.adOpenDynamic,LockTypeEnum.adLockOptimistic, 1)
oda.Fill (ds2,adoRS,"T_CODE_MEAN")

after fill,the rows in ds2.tables[0] has lose state
//ds2.WriteXml (StrWriter ,XmlWriteMode.DiffGram)
//dsXML = StrWriter.ToString()
//MessageBox.Show (dsXML)

if anyone could help me
THX!
  Reply With Quote
Old 16-03-2004, 03:49 PM   #2
Brian Parlier
Guest
 
Posts: n/a
Default Re: How to Fill a ADO RecordSet into DataSet with Changing state?

I am not really sure why you are using the RecordSet here. Based on your
code snippit I do not see any reason for it.

Try setting the AcceptChangesDuringFill property to false before you fill
the dataset.

This property marks the rows as new so any changes are not lost and will
allow you to update a database based on the inserted data.


Brian Parlier


"XiaS" <anonymous@discussions.microsoft.com> wrote in message
news:75D11CFB-05EE-4244-97A9-DD5CEBB45C55@microsoft.com...
> Hello!
> The problem is that when the RecordSet is in changing ,after oda.fill,the

All rows int DataSet.tables[0] will lose changing state;
>
> for example,there a ADOr.xml file:
> <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
> xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
> xmlns:rs='urn:schemas-microsoft-com:rowset'
> xmlns:z='#RowsetSchema'><s:Schema id='RowsetSchema'><s:ElementType

name='row' content='eltOnly' rs:CommandTimeout='30'
> rs:updatable='true'><s:AttributeType name='CODE_NAME' rs:number='1'

rs:writeunknown='true'
> rs:basecatalog='YSWebTest' rs:basetable='T_CODE_MEAN'
> rs:basecolumn='CODE_NAME' rs:keycolumn='true'><s:datatype dt:type='string'

rs:dbtype='str' dt:maxLength='40'
> rs:maybenull='false'/></s:AttributeType><s:AttributeType name='CODE_DESC'

rs:number='2' rs:nullable='true'
> rs:writeunknown='true' rs:basecatalog='YSWebTest'

rs:basetable='T_CODE_MEAN'
> rs:basecolumn='CODE_DESC'><s:datatype dt:type='string' rs:dbtype='str'

dt:maxLength='80'/></s:AttributeType><s:AttributeType name='CANMODIFY'
rs:number='3' rs:nullable='true'
> rs:writeunknown='true' rs:basecatalog='YSWebTest'

rs:basetable='T_CODE_MEAN'
> rs:basecolumn='CANMODIFY'><s:datatype dt:type='string' rs:dbtype='str'

dt:maxLength='1'/></s:AttributeType><s:AttributeType name='REMARKS'
rs:number='4' rs:nullable='true'
> rs:writeunknown='true' rs:basecatalog='YSWebTest'

rs:basetable='T_CODE_MEAN'
> rs:basecolumn='REMARKS'><s:datatype dt:type='string' rs:dbtype='str'

dt:maxLength='1000'/></s:AttributeType><s:extends
type='rs:rowbase'/></s:ElementType></s:Schema><rs:data><z:row CODE_NAME='9'
CODE_DESC='9' CANMODIFY='9' REMARKS='9'/><rs:insert><z:row CODE_NAME='8'
CODE_DESC='8' CANMODIFY='8' REMARKS='8'/></rs:insert></rs:data></xml>
>
> in this XML Data ,there a new row in insert state (rs:insert);
> then ,i read xml into a new ADO RecoredSet and fill into then DataSet

,like this code:
> OleDbDataAdapter oda = new OleDbDataAdapter ();
> ADODB.Recordset adoRS = new ADODB.Recordset();
> DataSet ds2 = new DataSet();
>

adoRS.Open(@"d:\ADOr.xml","Provider=MSPersist;",CursorTypeEnum.adOpenDynamic
,LockTypeEnum.adLockOptimistic, 1);
> oda.Fill (ds2,adoRS,"T_CODE_MEAN");
>
> after fill,the rows in ds2.tables[0] has lose state;
> //ds2.WriteXml (StrWriter ,XmlWriteMode.DiffGram);
> //dsXML = StrWriter.ToString();
> //MessageBox.Show (dsXML);
>
> if anyone could help me ?
> THX!



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off