display data from access onto form

Hi

I have visual C# 2005 express edition and MS-Access 2003 database.
I have a form with two fields first name and last name. I want to select data from a table in access and display it in the two form fields.
The SQL is
SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEE

Please help me.

Thanks
Anu
anumitAsked:
Who is Participating?
 
sabeeshCommented:
DataTable dt = null;
            OleDbConnection conn = new OleDbConnection(_accessConnString);
            try
            {
                conn.Open();
                OleDbCommand cmd = new OleDbCommand("SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEE", conn);
                OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds);
                dt = ds.Tables[0];
                conn.Close();
            }

also you need to import using System.Data.OleDb;
0
 
anumitAuthor Commented:
thanks, i will try it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.