Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how do I loop through a odbc recordset

Posted on 2009-05-12
2
Medium Priority
?
557 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 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