Simple accessprob

  • Thread starter Thread starter Lasse Edsvik
  • Start date Start date
L

Lasse Edsvik

Hello

have problems populating a listbox with data from an accessdb. cant figure
it out, have clicked "test connection" and it works but not this:

using System.Data;

using System.Data.OleDb;



/*

lots of code here

*/

private void button1_Click(object sender, System.EventArgs e)

{

OleDbConnection Conn = new
OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=;
Data Source=C:\db.mdb");

OleDbCommand SCmd = new OleDbCommand("SELECT * FROM Products");

OleDbDataAdapter pDA = new OleDbDataAdapter();

pDA.SelectCommand = SCmd;

DataSet DS = new DataSet();

pDA.Fill(DS,"Products");


listBox1.DataSource = DS;

}
 
Hi Lasse,

you didn't tell your DataAdapter which Connection to use.
You can use an overloaded Constructor to give'm the Connection Object.

Oliver
 
thanks Oliver
Oliver said:
Hi Lasse,

you didn't tell your DataAdapter which Connection to use.
You can use an overloaded Constructor to give'm the Connection Object.

Oliver
 
Back
Top