连接Access数据库

  private OleDbConnection GetCon()
        {
            string sPath = Application.StartupPath;
            string sDataSource ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ sPath.Substring(0, sPath.LastIndexOf("\\")).Substring(0, sPath.Substring(0, sPath.LastIndexOf("\\")).LastIndexOf("\\")) + "\\database\\test.mdb";
            OleDbConnection OleDbCon = new OleDbConnection(sDataSource);
            return OleDbCon;
        }

 

你可能感兴趣的:(Microsoft,Access)