Hello,

I have a combobox on my form that I need to be populated with data from a table in MS Access. I am new to coding in Visual c# and would appreciate any help I can get with this.

Thanks in advance,

SubProf

Hi SubProf... Welcome to Daniweb friend :)
i think you post thread in wrong forum..
this forum for vb not for c#...
please post in current forum -> C#

Hello,

I have a combobox on my form that I need to be populated with data from a table in MS Access. I am new to coding in Visual c# and would appreciate any help I can get with this.

Thanks in advance,

SubProf

Though this is not the right forum to reply but probably the following code should your answer. Follow it.

using system.data

oledb.oldedbconnection con;
string sql;
dataset ds=new dataset();
oledb.oledbDataAdaptar da;
int maxrows=0,i=0;

con=new oledb.oldedbconnection();
con.connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\STUDENT.MDB;Persist Security Info=False";
con.open();

sql="select name from information order by rollno";
da=new oledb.oledbDataAdaptar(sql,con);
da.fill(ds,"Information");

maxrows=ds.tables("Information").Rows.Count();

dropdownlist1.items.clear

for(;i<=maxrows-1;i++)
{
  dropdownlist1.items.add ds.tables("Information").Rows(i).Item("Name");
}

regards
Shouvik

choudhuryshouvi and Jx_Man,

Thank you for your help in solving my problem. Sorry I posted in the wrong forum.

Thanks again,

SubProf

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.