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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1252
29
C# Tutorial
1226
24
C# vs. C  : History, Evolution, and Future Prospects C# vs. C : History, Evolution, and Future Prospects Apr 19, 2025 am 12:07 AM

The history and evolution of C# and C are unique, and the future prospects are also different. 1.C was invented by BjarneStroustrup in 1983 to introduce object-oriented programming into the C language. Its evolution process includes multiple standardizations, such as C 11 introducing auto keywords and lambda expressions, C 20 introducing concepts and coroutines, and will focus on performance and system-level programming in the future. 2.C# was released by Microsoft in 2000. Combining the advantages of C and Java, its evolution focuses on simplicity and productivity. For example, C#2.0 introduced generics and C#5.0 introduced asynchronous programming, which will focus on developers' productivity and cloud computing in the future.

Golang and C  : Concurrency vs. Raw Speed Golang and C : Concurrency vs. Raw Speed Apr 21, 2025 am 12:16 AM

Golang is better than C in concurrency, while C is better than Golang in raw speed. 1) Golang achieves efficient concurrency through goroutine and channel, which is suitable for handling a large number of concurrent tasks. 2)C Through compiler optimization and standard library, it provides high performance close to hardware, suitable for applications that require extreme optimization.

Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Python vs. C  : Learning Curves and Ease of Use Python vs. C : Learning Curves and Ease of Use Apr 19, 2025 am 12:20 AM

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.

C   and XML: Exploring the Relationship and Support C and XML: Exploring the Relationship and Support Apr 21, 2025 am 12:02 AM

C interacts with XML through third-party libraries (such as TinyXML, Pugixml, Xerces-C). 1) Use the library to parse XML files and convert them into C-processable data structures. 2) When generating XML, convert the C data structure to XML format. 3) In practical applications, XML is often used for configuration files and data exchange to improve development efficiency.

Golang vs. C  : Performance and Speed Comparison Golang vs. C : Performance and Speed Comparison Apr 21, 2025 am 12:13 AM

Golang is suitable for rapid development and concurrent scenarios, and C is suitable for scenarios where extreme performance and low-level control are required. 1) Golang improves performance through garbage collection and concurrency mechanisms, and is suitable for high-concurrency Web service development. 2) C achieves the ultimate performance through manual memory management and compiler optimization, and is suitable for embedded system development.

What are the plugins for wordpress blocking ip What are the plugins for wordpress blocking ip Apr 20, 2025 am 08:27 AM

WordPress IP blocking plugin selection is crucial. The following types can be considered: based on .htaccess: efficient, but complex operation; database operation: flexible, but low efficiency; firewall: high security performance, but complex configuration; self-written: highest control, but requires more technical level.

How to parse next-auth generated JWT token in Java and get information in it? How to parse next-auth generated JWT token in Java and get information in it? Apr 19, 2025 pm 08:21 PM

In processing next-auth generated JWT...

See all articles