PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
How to Fill a ADO RecordSet into DataSet with Changing state?
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
How to Fill a ADO RecordSet into DataSet with Changing state?
![]() |
How to Fill a ADO RecordSet into DataSet with Changing state? |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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! |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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! |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

