Home Database Mysql Tutorial C++ Builder修改Access数据库密码

C++ Builder修改Access数据库密码

Jun 07, 2016 pm 03:31 PM
access builder c++ v Revise password database

void __fastcall TForm1::Button1Click(TObject *Sender){ AnsiString f1= AccoutMe.mdb ; // 源库1 AnsiString psw1= 123456; // 密码 1,若设置错误也会报“意外错误” AnsiString f2= AccoutMe_new.mdb ; // 源库2 AnsiString psw2= abc; // 新 密码 2 bo

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    AnsiString   f1= "AccoutMe.mdb ";           //   源库1
    AnsiString   psw1= "123456";                //   <strong>密码</strong>1,若设置错误也会报“意外错误”
    AnsiString   f2= "AccoutMe_new.mdb ";       //   源库2
    AnsiString   psw2= "abc";                   //   新<strong>密码</strong>2
    bool flg_Success = false;

    AnsiString   dir = ExtractFilePath(Application-> ExeName);
    f1=dir+f1;                              //新<strong>数据库</strong>绝对路径
    f2=dir+f2;

    if (FileExists( f2 ) )      //若目标文件已存在,先删除
            DeleteFileA(f2);

    char Provider1[512] = { 0 }, Provider2[512] = { 0 };

    sprintf(Provider1,
            "Provider=Microsoft.Jet.OLEDB.4.0;"
             "Data Source='%s';"
             "Jet OLEDB:Database Password='%s'" , f1, psw1
           );

//    sprintf(Provider2,
//            "Provider=Microsoft.Jet.4.0.OLE DB.Provider;"
//            "Data Source='%s';"
//            "Jet OLEDB:Database Password='%s'"
//            , f2, psw2
//            );   // 注意提供正确的Provider写法,否则提示“意外错误”

    sprintf(Provider2,
            "Provider=Microsoft.Jet.OLEDB.4.0;"
            "Data Source='%s';"
            "Jet OLEDB:Database Password='%s'" , f2, psw2
           );

    Variant Adoobj = Variant::CreateObject( "JRO.JetEngine");
    
    try
    {
        Adoobj.OleProcedure( "CompactDatabase", WideString(Provider1), WideString(Provider2) );

        if (FileExists(f1))
            DeleteFileA(f1);

        RenameFile(f2, f1);

        flg_Success = true;
    }
    __finally
    {
        Adoobj.Clear();
        Adoobj = Unassigned;
    }
    ShowMessage( BoolToStr(flg_Success, true) ) ;

}
Copy after login


这是OLE的方法,由于代码较简洁就不多写注释了。

原帖子见:http://topic.csdn.net/u/20120214/17/6bde8f44-3afb-4f8d-afc1-f971c879e3d9.html 

特别感谢老妖!

 

PS:

OLE报错太不友好了。

不论是用独占方式打开ACCESS用SQL语句ALTER DATABASE PASSWORD "旧密码"   "新密码",

还是用ADOQuery等控件,设置独占打开方式和 ADO 控件的SQL属性为"alter…………"修改ACCESS密码,都没有成功。

调试中ing...

 

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to convert deepseek pdf How to convert deepseek pdf Feb 19, 2025 pm 05:24 PM

DeepSeek cannot convert files directly to PDF. Depending on the file type, you can use different methods: Common documents (Word, Excel, PowerPoint): Use Microsoft Office, LibreOffice and other software to export as PDF. Image: Save as PDF using image viewer or image processing software. Web pages: Use the browser's "Print into PDF" function or the dedicated web page to PDF tool. Uncommon formats: Find the right converter and convert it to PDF. It is crucial to choose the right tools and develop a plan based on the actual situation.

What should I do if my Win10 password does not meet the password policy requirements? What to do if my computer password does not meet the policy requirements? What should I do if my Win10 password does not meet the password policy requirements? What to do if my computer password does not meet the policy requirements? Jun 25, 2024 pm 04:59 PM

In the Windows 10 system, the password policy is a set of security rules to ensure that the passwords set by users meet certain strength and complexity requirements. If the system prompts that your password does not meet the password policy requirements, it usually means that your password does not meet the requirements set by Microsoft. standards for complexity, length, or character types, so how can this be avoided? Users can directly find the password policy under the local computer policy to perform operations. Let’s take a look below. Solutions that do not comply with password policy specifications: Change the password length: According to the password policy requirements, we can try to increase the length of the password, such as changing the original 6-digit password to 8-digit or longer. Add special characters: Password policies often require special characters such as @, #, $, etc. I

How to implement the Strategy Design Pattern in C++? How to implement the Strategy Design Pattern in C++? Jun 06, 2024 pm 04:16 PM

The steps to implement the strategy pattern in C++ are as follows: define the strategy interface and declare the methods that need to be executed. Create specific strategy classes, implement the interface respectively and provide different algorithms. Use a context class to hold a reference to a concrete strategy class and perform operations through it.

Similarities and Differences between Golang and C++ Similarities and Differences between Golang and C++ Jun 05, 2024 pm 06:12 PM

Golang and C++ are garbage collected and manual memory management programming languages ​​respectively, with different syntax and type systems. Golang implements concurrent programming through Goroutine, and C++ implements it through threads. Golang memory management is simple, and C++ has stronger performance. In practical cases, Golang code is simpler and C++ has obvious performance advantages.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to implement nested exception handling in C++? How to implement nested exception handling in C++? Jun 05, 2024 pm 09:15 PM

Nested exception handling is implemented in C++ through nested try-catch blocks, allowing new exceptions to be raised within the exception handler. The nested try-catch steps are as follows: 1. The outer try-catch block handles all exceptions, including those thrown by the inner exception handler. 2. The inner try-catch block handles specific types of exceptions, and if an out-of-scope exception occurs, control is given to the external exception handler.

How does Go WebSocket integrate with databases? How does Go WebSocket integrate with databases? Jun 05, 2024 pm 03:18 PM

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.

How to iterate over a C++ STL container? How to iterate over a C++ STL container? Jun 05, 2024 pm 06:29 PM

To iterate over an STL container, you can use the container's begin() and end() functions to get the iterator range: Vector: Use a for loop to iterate over the iterator range. Linked list: Use the next() member function to traverse the elements of the linked list. Mapping: Get the key-value iterator and use a for loop to traverse it.

See all articles