示例#1
0
        protected override DbFileStoredConnection CreateStoredConnection()
        {
            AccessStoredConnection stored = new AccessStoredConnection();

            stored.Provider = AccessStoredConnection.GetProviderForFile(m_file.DataDiskPath);
            return(stored);
        }
示例#2
0
        AccessStoredConnection GetStoredConn()
        {
            AccessStoredConnection con = new AccessStoredConnection();

            con.UseAutentization = m_authFrame.UseAutentization;
            con.Password         = m_authFrame.Password;
            con.Login            = m_authFrame.Login;
            con.SystemDatabase   = m_authFrame.SystemDatabase;
            con.DbFilename       = OpenFileName;
            con.Provider         = AccessStoredConnection.GetProviderForFile(OpenFileName);
            return(con);
        }
示例#3
0
 public override void DoCreateFile(string filename)
 {
     byte[] data;
     if (SelectedVersion == V2000)
     {
         data = NewFiles.emptydb_2000;
     }
     else
     {
         data = NewFiles.emptydb_2007;
     }
     data = Compression.ZlibDecompress(data);
     if (SelectedVersion == V2000)
     {
         filename = Path.ChangeExtension(filename, ".mdb");
     }
     if (SelectedVersion == V2007)
     {
         filename = Path.ChangeExtension(filename, ".accdb");
     }
     using (FileStream fw = new FileStream(filename, FileMode.Create))
     {
         fw.Write(data, 0, data.Length);
     }
     if (m_authFrame.UseAutentization)
     {
         var con = new AccessStoredConnection();
         con.DbFilename       = filename;
         con.FileName         = filename + ".con";
         con.UseAutentization = true;
         con.Password         = m_authFrame.Password;
         con.Provider         = AccessStoredConnection.GetProviderForFile(con.DbFilename);
         con.Save();
         using (OleDbConnection conn = new OleDbConnection(con.GenerateNoPwdNoShareConnectionString()))
         {
             conn.Open();
             using (OleDbCommand cmd = conn.CreateCommand())
             {
                 cmd.CommandText = String.Format("ALTER DATABASE PASSWORD `{0}` ``", m_authFrame.Password);
                 cmd.ExecuteNonQuery();
             }
         }
     }
 }