views:

150

answers:

0

The ADO Recordset code below do not return any records in the code below. The ADO Command object and the ADO Connection works fine against my Access 2010 beta db.

I can Insert records, but not retrieve any. Any help is greatly appreciated.

:)=

THIS WORKS:
 string sMSAccess = "C:\\Users\\storltx\\Documents\\SL4Demo.accdb";

            try
            {
                using (dynamic ADOConnection = ComAutomationFactory.CreateObject("ADODB.Connection"))
                using (dynamic ADOCommand = ComAutomationFactory.CreateObject("ADODB.Command"))
                {
                    ADOConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sMSAccess + ";Persist Security Info=False";
                    ADOConnection.Open();
                    ADOCommand.ActiveConnection = ADOConnection;

                    ADOCommand.CommandText = @"INSERT INTO SL4Table ( [First], [Last] ) VALUES ('ABC', 'DEFG')";

                    ADOCommand.Execute();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.InnerException.Message);
            }

THIS DOES NOT:

    string sMSAccess = "C:\\Users\\storltx\\Documents\\SL4Demo.accdb";


                try
                {

                    using (dynamic AdoConnection = ComAutomationFactory.CreateObject("ADODB.Connection"))
                    using (dynamic AdoCommand = ComAutomationFactory.CreateObject("ADODB.Command"))
                    {
                        AdoConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sMSAccess + ";Persist Security Info=False";
                        AdoConnection.Open();
                        AdoCommand.ActiveConnection = AdoConnection;

                        AdoCommand.CommandText = @"SELECT * FROM SL4Table";


                        // dynamic AdoReader = ComAutomationFactory.CreateObject("ADODB.recordset");
                        // AdoReader.Open(@"Select * From SL4Table", AdoConnection);
                        // dtGrid.ItemsSource = AdoReader;


                        dtGrid.ItemsSource = AdoCommand.Execute();

                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.InnerException.Message);
                }