//add these for Access databases. Add a DataGridView Control to the Form using namespace System::Data; using namespace System::Data::OleDb; private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { try { //---STEP 1 :CONNECTION STRING (the dot "." means current machine. We use SQL Express in VStudio String^ connectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= customers.mdb"; //---STEP 2: CONNECTION OBJECT(uses the connString) OleDbConnection^ connection = gcnew OleDbConnection(connectionString); //---STEP 3 MAKE SQL STRING(to define which records to get) String^ queryString = "SELECT * from Customers ORDER BY LastName"; //---STEP 4 DATA ADAPTER (uses our SQL and Conn) OleDbDataAdapter^ adapter = gcnew OleDbDataAdapter(queryString, connection); //---STEP 5 DATASET(give the dataSet a name that relates to the data you want to display) DataSet^ customersDS = gcnew DataSet(); //---STEP 6 FILL THE DATA ADAPTER adapter->Fill(customersDS, "Customers"); //---STEP 7 SET DATAGRID PROPERTIES dataGridView1->DataSource = customersDS; dataGridView1->DataMember = "Customers"; //---always close connection->Close(); } catch(OleDbException^ ex) { MessageBox::Show("Error connecting to the database: " + ex->Message + "\n", "SQL Database Demo", MessageBoxButtons::OK, MessageBoxIcon::Error); } }