Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:13:18+00:00 2026-06-10T04:13:18+00:00

Below it the code I’m using to connect to an Access database and pull

  • 0

Below it the code I’m using to connect to an Access database and pull the values from the query. Problem is.. I cannot get any values back from the reader object. I can see that there are the correct amount of rows, however I keep getting an InvalidOperationException (whether I use GetValue() or GetString()) saying “No data exists for the row/column.”

        System.Data.OleDb.OleDbConnection conn = new
        System.Data.OleDb.OleDbConnection();
        conn.ConnectionString = @"Provider=Microsoft Office 12.0 Access Database Engine OLE DB Provider;" +
                                @"Data source= C:\Users\nearod\Desktop\ImportDB.accdb";
        try
        {
            conn.Open();
            OleDbCommand cmd = new OleDbCommand("SELECT * FROM [SQL Agent Unique ID Test Load]", conn);

            OleDbDataReader reader = cmd.ExecuteReader();

            string companyCode = reader.GetValue(0).ToString();
            string agentId = reader.GetString(1);
            string firstName = reader.GetString(2);
            string lastName = reader.GetString(3);
            string nameSuffix = reader.GetString(4);
            string corporateName = reader.GetString(5);
            string entityType = reader.GetString(6);
            string obfSSN = reader.GetString(7);
            string obfFEIN = reader.GetString(8);
            string dummyIndicator = reader.GetString(9);
            // Insert code to process data.
        }
        catch (Exception ex)
        {
            MessageBox.Show("Failed to connect to data source");
        }
        finally
        {
            conn.Close();
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:13:19+00:00Added an answer on June 10, 2026 at 4:13 am

    you have to call Read method like below (use using instead of disposing yourself connection

    string connectionString = @"Provider=Microsoft Office 12.0 Access Database Engine OLE DB Provider;" + @"Data source= C:\Users\nearod\Desktop\ImportDB.accdb";
    
    string queryString=  "SELECT * FROM [SQL Agent Unique ID Test Load]";
     try
         {
        using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                OleDbCommand command = new OleDbCommand(queryString, connection);
                connection.Open();
                OleDbDataReader reader = command.ExecuteReader();
    
                while (reader.Read())
                {
                    string companyCode = reader.GetValue(0).ToString();
                string agentId = reader.GetString(1);
                string firstName = reader.GetString(2);
                string lastName = reader.GetString(3);
                string nameSuffix = reader.GetString(4);
                string corporateName = reader.GetString(5);
                string entityType = reader.GetString(6);
                string obfSSN = reader.GetString(7);
                string obfFEIN = reader.GetString(8);
                string dummyIndicator = reader.GetString(9);
                // Insert code to process data.
                }
                reader.Close();
            }
       }
    catch (Exception ex)
       {
                MessageBox.Show("Failed to connect to data source");
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below code is for donwnloading file from azure blob. I have problem with .docx,.xlsx
Below code display the list populated from database(DB code is not included). If I
from below code i am able to get the MMS but the date is
Partial Code: My below code pulls a query from my DB and then uses
below code: def http = new HTTPBuilder( 'http://twitter.com/statuses/' ) http.get( path: 'user_timeline.json', query: [id:'httpbuilder',
below code is my databasehandler class i got it from a tutorial. Beside that
HI: Below code is from RequestFactoryEditorDriver: /** * Returns a new array containing the
Below code is the response from the server: xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema><soap:Body><SendCardDetailsResponse xmlns=http://tempuri.org/><SendCardDetailsResult><ROOT xmlns=><DocumentElement><res-auth><auth-data count='1' ><**attribute
The below code works fine when i am not adding any extra row all
Below code works well, its able to replace any tag it find with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.