Link dropdown to Access database

C

Christian Ista

Hello,

In an Access database, I have 2 fields "id" and "category", the table name
is "category".

In the Page_Load, I have this :
DropDownList1.DataSource = Common.getCategory();
DropDownList1.DataBind();

In the getCategory, I have this :

public static DataSet getCategory()
{
string connection = getConnectionString();
string query="SELECT * FROM Category";

DataSet dataset = new DataSet();
OleDbConnection conn = new OleDbConnection(connection);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(query, conn);
adapter.Fill(dataset,"category");
return dataset;
}

Compilation ok, but when I execute, I have in the dropdown 5 lines (the
number of record in the table) "System.data.DataRowView".

Could tell me how to do to have the "category" field in the dropdown.

Thanks,

Christian,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top