Solved

how do I loop through a odbc recordset

Posted on 2009-05-12
2
550 Views
Last Modified: 2013-12-17
I am a beginner in c# and would like to know how to loop through records in a db. It could be a recordset, etc. I need to be able to loop through items in a db table and update a filed in that row.
OdbcConnection con1 = new OdbcConnection(ConnStr);
 
            OdbcCommand cmd1 = new OdbcCommand("SELECT * from testupdate", con8);
            con1.Open();
            cmd1.ExecuteNonQuery();
            con1.Close();

Open in new window

0
Comment
Question by:bschave2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
GuitarRich earned 500 total points
ID: 24364999
Use a datareader
OdbcConnection con1 = new OdbcConnection(ConnStr);
 
            OdbcCommand cmd1 = new OdbcCommand("SELECT * from testupdate", con8);
            con1.Open();
            OdbcDataReader dr = cmd1.ExecuteReader()
            
            // To loop through
            while (dr.Read())
            {
                // deal with the data here
            }
            dr.Close();
            con1.Close();

Open in new window

0
 

Author Comment

by:bschave2
ID: 24365287
thanks for the help.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question