Solved

how do I loop through a odbc recordset

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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 …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now