How can I connect Borland C++ builder 6 and oracle 10g?? [message #476718] |
Fri, 24 September 2010 15:17 |
subhapam
Messages: 2 Registered: September 2010
|
Junior Member |
|
|
//This is my program
//---------------------------------------------------------------
#include <vcl.h>
#include<odbcinst.h>
#include <windows.h>
#include <stdio.h>
#include <sql.h>
#include <sqlext.h>
#include <iostream.h>
#include <conio.h>
using namespace std;
int main()
{
//SQLCHAR *diagstate = new SQLCHAR[50];
SQLINTEGER native;
//SQLCHAR *msg1 = new SQLCHAR[255];
SQLSMALLINT outNo;
SQLHENV env;
SQLHDBC conn;
SQLHSTMT stmnt;
SQLRETURN ret;
long lStrLen;
char data[1000];
//Connect.
ret=SQLAllocEnv(&env);
ret=SQLAllocConnect(env,&conn);
ret=SQLConnect(conn,"project1",SQL_NTS,"system",SQL_NTS,"system",SQL_NTS);
if(ret==SQL_SUCCESS || ret==SQL_SUCCESS_WITH_INFO)
{
ret=SQLAllocStmt(conn,&stmnt);
ret=SQLPrepare(stmnt,(UCHAR*)"INSERT INTO TRIAL VALUES(2,'subha')",SQL_NTS);
if(ret==SQL_SUCCESS || SQL_SUCCESS_WITH_INFO)
{
ret=SQLExecute(stmnt);
printf("done!!!!");
}
//Disconnect
SQLFreeStmt(stmnt,SQL_DROP);
SQLDisconnect(conn);
SQLFreeConnect(conn);
SQLFreeEnv(env);
}
printf(".........");
getch();
}
//-------------------------------------------------------------
Whenever I compile or run this code. It gives the following error.
[Linker Error] Unresolved external '_SQLAllocEnv' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLAllocConnect' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLConnect' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLAllocStmt' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLPrepare' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLExecute' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLFreeStmt' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLDisconnect' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLFreeConnect' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
[Linker Error] Unresolved external '_SQLFreeEnv' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER6\PROJECTS\CONNECTION.OBJ
-----------------------------------------------------------------
My SYSTEM DSN is "project1" with USER ID "system" and PASSWORD "system" and the Table name is "TRIAL".
Please help me sorting out this problem.......
|
|
|
|
|
|
Re: How can I connect Borland C++ builder 6 and oracle 10g?? [message #476782 is a reply to message #476779] |
Sun, 26 September 2010 01:08 |
|
Michel Cadot
Messages: 68728 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Here 2 answers I got from outside:
Quote:You first need to set up and ODBC data sorce. You can do this by going to start->settings->control pannel->Administrative tools->Data Sources (ODBC)
Once you have set up your ODBC data source using the port and computername/ip for which the Oracle Database has been installed...you then can go to your start->settings->control pannel->BDE Administartor. Go to object->New then select database. Use the Oracle driver for your database.
Once all of that has been set up you should be able to drop a TTable onto your form or TDataModule and access the oracle database with the appriate table.
This should get you started in the right direction.
Quote:Or use the OCCI libraries from borland:
1) get the Delphi Direct ORACLE Access Components from: http://sourceforge.net/projects/delphioci/
2) create a new package in BCB6, put every .pas file found on the "src" folder of the delphioci project
3) add the DesignIntf.pas file to the package (it's fund under $(BCB)/Source/ToolsAPI)
4) build and install the package. This will give you the new following components:
TAMemoryDataset, TAOraSQL, TAOraUpdateSQL, TMemoryDataset, TOraDB, TOraSQL
they will all be under the "Data Access" toolbar
5) documentation for all these components is found on the "doc" folder of the delphioci package
Regards
Michel
[Updated on: Sun, 26 September 2010 01:12] Report message to a moderator
|
|
|
|