Advertisement

10.22.2004 at 01:52PM PDT, ID: 21179348
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

unexpected behaviour while filling a DataTable from a recordset

Asked by danial_m in Miscellaneous Programming

Tags: , ,

hi,
I've just encountered a problem while filling a DataTable from recordset using the OleDBDataAdapter.fill method.Once a table is filled ,no more tables can be filled by the same method and same recordset.
The recordset is intact and I can get the data by its methods,but the fill method returns no rows in the next calls.
nothing seems to be wrong ,and this behaviour is very odd.
can any body tell what's going wrong in here.
I added  a reference in my solution to the adodb PIA in .net pane of references(I test all of the versions and get the sanme results).
here is the code I used to test these with:




                  ADODB.Connection cn=new ADODB.ConnectionClass();
                  cn.ConnectionString="provider=sqloledb;server=HOME;database=northwind;uid=sa";
                  cn.Open(cn.ConnectionString,"sa","123",0);
                  ADODB.Recordset rs=new ADODB.RecordsetClass();
                  rs.CursorLocation=ADODB.CursorLocationEnum.adUseClientBatch;
                  rs.CursorType=ADODB.CursorTypeEnum.adOpenStatic;
                  rs.LockType=ADODB.LockTypeEnum.adLockOptimistic;
                  rs.Open("Select * from products",cn,rs.CursorType,rs.LockType,0);
                  rs.ActiveConnection=null;
                  cn.Close();
                  OleDbDataAdapter da=new OleDbDataAdapter();
                  DataTable dt=new DataTable("products");
            DataSet ds=new DataSet();
                  da.Fill(dt,rs);
                  ds.Tables.Add(dt);
                  Console.WriteLine("there are{0}rows",ds.Tables["products"].Rows.Count);
                  DataTable dt2=new DataTable();
                  DataSet ds2=new DataSet();
                  da.Fill(dt2,rs);                        //<--no rows is added to the table
                  ds2.Tables.Add(dt2);
                  Console.WriteLine("there are{0}rows",ds2.Tables[0].Rows.Count);Start Free Trial
[+][-]11.03.2004 at 08:23PM PST, ID: 12489995

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Miscellaneous Programming
Tags: datatable, dataset, filling
Sign Up Now!
Solution Provided By: atheekurrahman
Participating Experts: 1
Solution Grade: A
 
 
[+][-]12.14.2004 at 03:13PM PST, ID: 12825327

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12.19.2004 at 12:36AM PST, ID: 12860641

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32