Solved

how do I loop through a odbc recordset

Posted on 2009-05-12
2
545 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …

752 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