PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?WGlhUw==?=
Guest
Posts: n/a
 
      16th Mar 2004
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
 
 
 
 
Brian Parlier
Guest
Posts: n/a
 
      16th Mar 2004
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" <(E-Mail Removed)> wrote in message
news:75D11CFB-05EE-4244-97A9-(E-Mail Removed)...
> 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Second fill in Ado.recordset does not fill table Jamal Samedov Microsoft ADO .NET 4 4th Sep 2010 03:00 PM
Fill Dataset from linq to Dataset query =?Utf-8?B?SnVhbiBQdWVibGE=?= Microsoft C# .NET 0 28th Aug 2007 01:50 PM
obtain recordset of an object COM made in VB6 and soon fill dataset Yoel Mc Lennan Microsoft Dot NET 0 27th Jan 2006 06:57 PM
Using Recordset.State Property =?Utf-8?B?SWx5YQ==?= Microsoft Access Form Coding 11 19th Jul 2005 10:21 AM
How to fill multiple datatables in a dataset in a single fill Saladin Microsoft ADO .NET 5 29th Dec 2004 12:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:08 AM.