AGAIN database


 
Thread Tools Search this Thread
Top Forums Programming AGAIN database
# 1  
Old 10-24-2005
AGAIN database

THis is my program

#include <stdio.h>
#include "sqlext.h"
#include "sql.h"
#include <string.h>
#include<errno.h>

// #include "sqlunix.h"
#define STR_LEN 30
#define SQL_NTS (-3)
#define MYSQLSUCCESS(rc) ((rc==SQL_SUCCESS)||(rc==SQL_SUCCESS_WITH_INFO))



void main()
{
HENV henv; /* environment handle */
HDBC hdbc; /* connection handle */
HSTMT hstmt; /* statement handle */
SDWORD retcode; /* return code */
UCHAR info[STR_LEN]; /* info string for SQLGetInfo */
int rc=0;
unsigned char chr_ds_name[SQL_MAX_DSN_LENGTH]; // Data source name
// char chr_ds_name[]={"SQL"}; // Data source name
//strcpy(chr_ds_name,"SQL");


retcode = SQLAllocEnv(&henv);
retcode = SQLAllocConnect(henv,&hdbc);
retcode = SQLConnect(hdbc,chr_ds_name,SQL_NTS, NULL,0,NULL,0);

if (!MYSQLSUCCESS(rc))
{
SQLFreeEnv(henv);
SQLFreeConnect(hdbc);
// error_out();
exit(-1);
}
}


the error on compilation is :

Undefined first referenced
symbol in file
SQLConnect /var/tmp/ccnGf8ud.o
SQLAllocEnv /var/tmp/ccnGf8ud.o
SQLFreeEnv /var/tmp/ccnGf8ud.o
SQLAllocStmt /var/tmp/ccnGf8ud.o
SQLAllocConnect /var/tmp/ccnGf8ud.o
SQLFreeConnect /var/tmp/ccnGf8ud.o
ld: fatal: Symbol referencing errors. No output written to d
collect2: ld returned 1 exit status

i am compiling it as: g++ <filename.cpp>

what is this error
please do help me
# 2  
Old 10-24-2005
You have to link against the mysql client library, you probably should also point to the mysql include path, too:
Code:
g++ <filename.cpp> -L/usr/local/lib/mysql  -I/usr/  -I/usr/local/include/mysql

Exactly where the -L and -I point depend on where (and if) the library and include files ive on your system.

Which distibution of Linux?
# 3  
Old 10-25-2005
i have been working on solaris 5.8

i just want to know that what libraries u need to compile the database program

because i think i am working on older version of solaris so i dont have sql.h and sqlext.h header files also, but i downloaded those files form the net

somebody told me that i should use -lsql while compiling
like

g++ <filename.cpp> -lsql

i serached it in all the possible directories of my system but i couldnt get it

1)so i am unable to understand which files u need to include and what libraries u need when u want a database to be connected to c++.

2) if the libraries of database r not in the system then from where we can download it
# 4  
Old 10-25-2005
I'm assuming mysql.

If you want me to help you HAVE to tell me the name of the DATABASE ENGINE.
# 5  
Old 10-26-2005
i have been trying to connect Microsoftsql serevr to solaris 5.8 using c++
# 6  
Old 10-28-2005
These function calls look like ODBC calls so I'm assuming you're trying to use unixODBC. If not, you're gonna need it because Microsoft ODBC hasn't been ported to unix yet, and isn't likely to be anytime this millenium Smilie

They have a faq entry relating to this very problem. In short you need to link with -lodbc .
# 7  
Old 10-30-2005
hi corona

i tried to compile my above program with -lodbc and -lsql (both seperatley and togther) but it is giving error as


ld: fatal: library -lsql: not found
ld: fatal: File processing errors. No output written to a.out
collect2: ld returned 1 exit status

ld: fatal: library -lodbc: not found
ld: fatal: File processing errors. No output written to a.out
collect2: ld returned 1 exit status

I dont Know what to do now
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CRON Job to copy database and replace existing database

I have a reseller account with hostgator, which means i have WHM and Cpanel. I have set up a staging environment for one of my wordpress installations (client website), which is essentially sitting at staging.domain.com (live site is at domain.com). The staging website is a complete copy of the... (1 Reply)
Discussion started by: nzrobert
1 Replies

2. Shell Programming and Scripting

Database is down

How to find out whether your database is down or not? Could anyone provide me the command please.. Thanks C (6 Replies)
Discussion started by: bobby1015
6 Replies

3. Solaris

Can't create database after Oracle Database installation

I installed Oracle 10 software on Solaris 11 Express, everything was fine execpt I can't create database using dbca.rsp file. I populated file with following options. OPERATION_TYPE = "createDatabase" GDBNAME = "solaris_user.domain.com" SID = "solaris_user" TEMPLATENAME = "General... (0 Replies)
Discussion started by: solaris_user
0 Replies

4. Solaris

redirect solaris database from linux database..

hi.. i have a need .. my php runs on my linux redhat box with mysql.. i want my php code to refer another mysql database which is in solaris 10 x86... can u tell me the procedure .. how it can be done through php .. sorry am new to php... is it possible to redirect from linux mysql to... (7 Replies)
Discussion started by: senkerth
7 Replies

5. UNIX for Dummies Questions & Answers

Updating a database

i've got a database setup that references user inputs to see if they are already inputted. What I am wanting to do is allow the user to update the database by typing "update: name" where name is someone already in the database. echo "Enter your name." read NAME location=`find . -name... (2 Replies)
Discussion started by: fufaso
2 Replies

6. Programming

database in C

how can we connect to database(psql) using c language?. Any one help.Pls say the hader file and function's avilable in C for database operation(like connecting,selecting,etc...). (3 Replies)
Discussion started by: sabari
3 Replies

7. Linux

Database

Hai , can any one suggest me any site where the mysql tutor for linux is avialable i am new to the linux mysql so i want to know right from the basics and how can i connect those database to planner tool in linux :) Regards Sanju (1 Reply)
Discussion started by: sanjustudy
1 Replies

8. UNIX for Dummies Questions & Answers

Database

I am looking for a database that i can use on Red Hat Linux 8.0. I wish to store records about my clients in it. I do not wish for i to be used on a server (3 Replies)
Discussion started by: adminbw
3 Replies

9. Programming

help in using database in c++

help me in using database in c++ whether datas entered in c++ can be stored in Oracle or access database? give a hint (1 Reply)
Discussion started by: sajin_george
1 Replies
Login or Register to Ask a Question