Exemplo n.º 1
0
        private void btnCatsFromLocal_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            string connectionPrefix = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=";
            string client           = new Uri(dmc.origUrl).Host;
            string filename         = client + ".mdb";
            string app_data         = Path.GetDirectoryName(Application.ExecutablePath) + @"\App_data\";
            string dest             = app_data + filename;

            if (!File.Exists(dest))
            {
                MessageBox.Show("Cannot find data file");
                return;
            }
            string connection = connectionPrefix + dest;

            using (CategoryTableAdapter catsda = new CategoryTableAdapter())
            {
                catsda.SetConnection(new OleDbConnection(connection));
                LocalCats.CategoryDataTable cats = new LocalCats.CategoryDataTable();
                catsda.Fill(cats);
                catsGrid.DataSource = cats;
            }
            Cursor.Current = Cursors.Default;
            return;
        }