Oracle OLE DB packaged and integrated into the program installation package (VC ADO Access Oracle)

Source: Internet
Author: User
Tags ole

Recently there was a project with Oracle interaction that I was using ADO to do.

First, the database connected to the East record, the old memory is not good ah!

The operation is as follows:

Connection string so that you can not configure the Tnsnames.ora configuration file (many tutorials on the web to change the configuration file)

Strconnect.format ("PROVIDER=ORAOLEDB.ORACLE.1; password=%s; Persist Security info=true; User id=%s;\
Data source=\ "(DESCRIPTION = (Address_list = (ADDRESS = (PROTOCOL = TCP) (HOST =%s) (PORT =%s)) (Connect_data = (SID =%s)) )\"",
Strpwd, Struid, Strhost, Strport, Strsid);


hr = M_pconnection.createinstance (__uuidof (Connection));
Try
{
M_pconnection->connectiontimeout = Lconnecttime;
hr = M_pconnection->open ((LPCTSTR) strconnect, "", "", adModeUnknown);
if (FAILED (HR))
{
Sharedata.g_pmainframe->alert (_t ("Database connection failed, please check database!"));
return FALSE;
}
}
catch (_com_error e)
{
CString err;
Err. Format (_t ("Database connection Error! \ r \ n Error message:%s: "), E.errormessage ());
Sharedata.g_pmainframe->alert (ERR);
return FALSE;
}

M_bconnectdb = TRUE;

Querying data section

if (M_puserrecset)
{
if (m_puserrecset->state)
M_puserrecset->close ();
M_puserrecset = NULL;
}
try{
M_puserrecset.createinstance (__uuidof (Recordset));
M_puserrecset->open ("SELECT * from XXX", m_pconnection.getinterfaceptr (), \
adOpenDynamic,/*adopenstatic, * *
adLockOptimistic, adCmdText);
}
catch (_com_error& e)
{
AfxMessageBox (e.description () + E.source ());
Return
}

//....

Then pack the release, install the program after a run popup data connection error, Baidu, Google know it needs to install Oracle OLE DB Provider

Know the reason is good to do, lack what to mend what!

Http://www.oracle.com/technetwork/database/windows/utilsoft-088126.html


Download the ODAC101040.exe after installation, the database operation is normal!

To this run our system simply installs our package and ODAC101040.exe in Oracle Provider for OLE DB ... Component.

Development to the people think it can, quite simple, and then sent to the customer use.

I didn't expect the client to jump up and shout loudly:

1. Two-step installation is too complicated.

2. odac101040 more than 100 m too big

3. What we want is a bag, fool-like point must be able to use, change, must change, immediately change ...

Alas, the customer is God, can only humble himself to buy a little time.

Also swap position thinking, if I am a customer also do not want to toss, programmer is to pursue perfection, embrace change, in the change to achieve self, hehe, pull an egg!

The requirements are clear: The Oracle Provider for OLE DB-related Dongdong is integrated into the program installation package, and the installation package cannot be too large!

Almighty Internet, let me find an article: http://blog.csdn.net/dux003/article/details/5657531 (Thanks to the author)

The steps are as follows:

1. Extract Oracle-related files by "Oracle OLE DB Minimum installation package " Tutorial

2. Download and install the Wise Installation System-professional Edition to create the installation package (online tutorial, omitted)

According to the above steps to make or spend a day, the main is the minimum installation package in the "installation process" description is rough, mainly I do not install the package is not the line, most of the time spent in this, hey

Some points of attention are as follows:

1. Wise installation does not need to export key as mentioned in step 1 related articles, you can package the entire registry key

2. I put the file Oracle into the program directory and then modify the entries in the registry (I modified all the entries):

Note: The path of the registry can be specified dynamically with%maindir%

3. Add Oracle to the environment variables, the interface does not know how to add, with the script added, I added to the last:

To this Oracle integration package is over.

Then uninstall the ODAC101040.exe related services, then click on the installation package to start the installation, expect exciting moments to come, etc...

No excitement, wait until the database Edge connection Error!!!

After restarting the computer, hey, do not appear database connection error, a little joy, but there is another more headache error:

Online http://blog.csdn.net/dragoo1/article/details/10138847 This file seems to have feelings, but we're not servers ah, check environment variables

Finally suspected bin DLL is not complete, all the Oracle/bin directory copied over, try again, but seems a bit more, see the above error should be OLE DB related

Once again, put (the remaining OraOLEDB related DLLs in the original bin)

OraOLEDB10zhs.dll

OraOLEDBrfc10.dll

OraOLEDBrmc10.dll

Copy it in!

Run again, and the exciting moments really come!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.