[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

display data from access onto form

Posted on 2007-08-03
2
Medium Priority
?
182 Views
Last Modified: 2013-12-17
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
0
Comment
Question by:anumit
2 Comments
 
LVL 8

Accepted Solution

by:
sabeesh earned 500 total points
ID: 19626682
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
 

Author Comment

by:anumit
ID: 19626812
thanks, i will try it
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question