DataSet Binding Question  
Author Message
steve_comcast2007





PostPosted: Wed Oct 08 10:44:30 CDT 2003 Top

ADO >> DataSet Binding Question Hi,

I am having problems with binding a dataset to a combo box. I have created
an query in Access 2002 called procModels. I want to be able to call it and
retrieve the data from the query. I have included some code below. Any
help will be appreciated.

sql = "EXECUTE procModels";
OleDbConnection dbConn = new OleDbConnection(connString);
OleDbDataAdapter dbAdapter = new OleDbDataAdapter(sql, dbConn);
DataSet ds = new DataSet();
dbAdapter.Fill(ds, "tblModels");
return ds;

databinding code:
this.modelComboBox.DataSource = ds.Tables["tblModels"];

Thanks in adavance
this.modelComboBox.DisplayMember = "tblModels.strCode";

DotNet221  
 
 
John





PostPosted: Wed Oct 08 10:44:30 CDT 2003 Top

ADO >> DataSet Binding Question Nevermind I figured it out. In the code 'this.modelComboBox.DisplayMember =
"tblModels.strCode"' it was wrong I did not need to specify the tbl name.

"John" <EMail@HideDomain.com> wrote in message
news:EMail@HideDomain.com...
> Hi,
>
> I am having problems with binding a dataset to a combo box. I have
created
> an query in Access 2002 called procModels. I want to be able to call it
and
> retrieve the data from the query. I have included some code below. Any
> help will be appreciated.
>
> sql = "EXECUTE procModels";
> OleDbConnection dbConn = new OleDbConnection(connString);
> OleDbDataAdapter dbAdapter = new OleDbDataAdapter(sql, dbConn);
> DataSet ds = new DataSet();
> dbAdapter.Fill(ds, "tblModels");
> return ds;
>
> databinding code:
> this.modelComboBox.DataSource = ds.Tables["tblModels"];
>
> Thanks in adavance
> this.modelComboBox.DisplayMember = "tblModels.strCode";
>
>