Hi to all...Hope everyone is grand.I am currently working on a project that is supposed to connect to a .mdb(access) file and than bring out the project names in to the first listbox (listbox1) than when you click one of the elements in listbox1 you would get the selected projects ip numbers which will be displayed in another listbox(listbox3).My problem is with my OleDbDataReader I think...because when I debugged my file step by step it gave an "No value give for one or more required parameters" error.I haven't figured out why since the db1.mdb (database) file was indeed full.I have posted the design part of the code.For the full source file please click here.I have used Microsoft Visiual Studio 2005 as my code compiler.Please help I am currently very stuck...Thanks in advance...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data.Odbc;
using System.Data.Common;

namespace WindowsApplication1
{
    public partial class Browser1 : Form
    {
        string selectedfr;
        public Browser1()
        {
            InitializeComponent();
           
        }

        private void Browser1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'db1DataSet1.Projects' table. You can move, or remove it, as needed.
            this.projectsTableAdapter1.Fill(this.db1DataSet1.Projects);
            // TODO: This line of code loads data into the 'db1DataSet.Projects' table. You can move, or remove it, as needed.
            this.projectsTableAdapter.Fill(this.db1DataSet.Projects);
            this.projectsTableAdapter1.FillBy1(this.db1DataSet1.Projects);
            string selcting = listBox1.SelectedItem.ToString();
            

            
            

        }
        private void showing()
        {
           
            
           
            //create the database connection
            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb");

            //create the command object and store the sql query
            OleDbCommand aCommand = new OleDbCommand("SELECT IP FROM Projects WHERE (CompanyName = " + selectedfr + " )", aConnection);
            MessageBox.Show("" + selectedfr + "");
            try
            {
                aConnection.Open();

                //create the datareader object to connect to table
                OleDbDataReader aReader = aCommand.ExecuteReader();
                

                //Iterate throuth the database
                while (aReader.Read())
                {
                    listBox2.Items.Add(aReader.GetData(2).ToString());
                }

                //close the reader 
                aReader.Close();

                //close the connection Its important.
                aConnection.Close();
            }

            //Some usual exception handling
            catch (OleDbException e)
            {
                MessageBox.Show("Error: {0} "+ e.Errors[0].Message);
            }

        }

        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void fillByToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.projectsTableAdapter1.FillBy(this.db1DataSet1.Projects);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }

        private void fillBy1ToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.projectsTableAdapter1.FillBy1(this.db1DataSet1.Projects);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }

        private void fillBy1ToolStripButton_Click_1(object sender, EventArgs e)
        {
            try
            {
               
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }

        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
           
        }

        private void button8_Click(object sender, EventArgs e)
        {
         

            this.Close();

        }

        public void listBox1_MouseClick(object sender, MouseEventArgs e)
        {
            selectedfr =listBox1.Text.ToString();
            showing();
        }

      
    }
}

Ok.I found out how I can get rid of the problem...wish someone helped me until now...i was quite crestfallen when everybody acted as tough noone knew anything about data reading or writing in c#....and if indeed no one knew well again a sad case for the developer world...
Anyways...I found out that my program while executing tried to read from a null index of an .mdb file....I finished the project.But I will not post it here for two reasons:
1-The program is more than 2mb(without re-distrubatable .Net framework 2.0)
2-I would like to help the person who I will give the program to personally so he will understand the program completely
3-No one even commented on my question....I did not even get one single example,explanation,a question on my question or anything like that....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.