0

I'm trying to compile some code in Visual C# Express.
Would someone please have a gander and help me out by giving me a brife explanation of why I'm getting an error "oleDbDataAdapter is not in the current context"?

From my understanding (which must be wrong) oleDbDataAdapter is part of System.Data.Oledb context.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;

namespace WindowsFormsApplication1
{
  
    public partial class formProcessor : Form
    {
        public formProcessor()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
// Put all file names in root directory into array.
            string[] array1 = Directory.GetFiles(@"C:\documents and settings\All Users\Documents\IGRT\", "*.jpg");  
// Connect to mdb
            string connetionString = null;
            System.Data.OleDb.OleDbConnection cnn;
            connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\All Users\\Documents\\IGRT\\shifts.mdb;";
            cnn = new System.Data.OleDb.OleDbConnection(connetionString);
            try
            {
                cnn.Open();
                MessageBox.Show("Connection Open ! ");
                cnn.Close();
            }
            catch
            {
                MessageBox.Show("Can not open connection ! ");

            }
 //increment for softName           
            int x = 0;       
            foreach (string name in array1)
            {
                x++;
                string sql = "SELECT * FROM ShiftTable WHERE imgName = \'"+(name)+"\'";
                oleDbDataAdapter.SelectCommand.CommandText;  //getting error message here
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Momerath
0

I don't see anywhere in your code that you declare the variable oleDbDataAdapter, which is what the error is telling you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.