Hey all. I'm trying to return a single value based on a listbox that I've set to display the first column in my database (an .mdb - using Jet, or OLEDB). When the user clicks on an entry in the listbox, I need my program to return the single value from a different column. How?
I have this already (please ignore all the idiot proofing comments I've made. mdd_0825 is the .mdb):
public partial class MainForm : Form // This is the class-header
{
// Step 1 - Create the connection object
OleDbConnection m_cnADONetConnection = new OleDbConnection();//This is a module - level variable to hold the connection
//Step 4 - Create the Data Adapter Object
OleDbDataAdapter m_daDataAdapter;
//Step 5 - need a way to customize how updates are submitted
OleDbCommandBuilder m_cbCommandBuilder;//We don't work with this - it does everything behind the scenes, but we have to attach it to the data adapter
//Step 6 - create the DataTable
DataTable m_dtmdd_0825 = new DataTable();
//Step 7 - We need to keep track of the row we're on in the Table
int m_rowPosition;

public MainForm()
{
InitializeComponent();
}

private void MainForm_Load(object sender, EventArgs e)
{
//Step 2 - Specify the ConnectionString Property in the Load Event (SET THE CONNECTION STRING)
m_cnADONetConnection.ConnectionString = @"Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\temp\mdd_0825.mdb";
//Step 3 - open the connection
m_cnADONetConnection.Open();
//Step 5 - Use the Adapter to perform commands
m_daDataAdapter = new OleDbDataAdapter("Select * From mdd_0825", m_cnADONetConnection);
OleDbCommandBuilder m_cbCommandBuilder = new OleDbCommandBuilder(m_daDataAdapter);
//Step 8 - Fill DataTable with data
m_daDataAdapter.Fill(m_dtmdd_0825);


}
private void button1_Click(object sender, EventArgs e)
{
DataRow m_rwmdd_0825 = m_dtmdd_0825.Rows[0];

MessageBox.Show(m_rwmdd_0825["PRBE"].ToString());
}
The button click at the end is just me trying to test the connection out. It returns the indexed value ([0] - the first row, and the column name ["PRBE"]) as a string, but I need this to be a listbox that the user clicks on an entry from the first column and the program returns the single value from the "PRBE" column. Thanks for any reply.