天天看點

c#連接配接access資料庫,把資料庫包括在項目中

 string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=gjqzmp.mdb;";

            OleDbConnection myCon = new OleDbConnection(conStr);

            try

            {

                myCon.Open();

                 MessageBox.Show("Success!" + myCon.State.ToString());

            }

            catch

            {

                MessageBox.Show("access資料庫連接配接失敗!");

            }

            finally

            {

                myCon.Dispose();

                myCon.Close();

            }