472,967 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,967 software developers and data experts.

SQLExecDirect in C++

1
Hi

i am using the following code for my development work
[code=c]
/* Connect to data source */

retcode = SQLConnect(hdbc, (SQLCHAR*) "mvr", SQL_NTS,
(SQLCHAR*) "venk", SQL_NTS,
(SQLCHAR*) "ram", SQL_NTS);

if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){
/* Allocate statement handle */
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);

if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Process data */
unsigned char query1[256];
sprintf((char*)query1,
"SELECT [col1], [col2], FROM MY_DATA WHERE
Expand|Select|Wrap|Line Numbers
  1.  = \'%s\' ",
  2.                 pszCode );
  3.  
  4.               retcode = SQLExecDirect( hstmt, (SQLCHAR *)query1, SQL_NTS);
  5.  
  6. //////////////////////////////
  7.  
But above code is unable to retrive the data from DB.

Can you please give me any suggestions.

where as same query if i run in sql analyzer the values are coming correctly.

Thanks in advance

Venkat
Mar 18 '08 #1
1 5502
sicarie
4,677 Expert Mod 4TB
Hi

i am using the following code for my development work
[code=c]
/* Connect to data source */

retcode = SQLConnect(hdbc, (SQLCHAR*) "mvr", SQL_NTS,
(SQLCHAR*) "venk", SQL_NTS,
(SQLCHAR*) "ram", SQL_NTS);

if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO){
/* Allocate statement handle */
retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);

if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
/* Process data */
unsigned char query1[256];
sprintf((char*)query1,
"SELECT [col1], [col2], FROM MY_DATA WHERE
Expand|Select|Wrap|Line Numbers
  1.  = \'%s\' ",
  2.                 pszCode );
  3.  
  4.               retcode = SQLExecDirect( hstmt, (SQLCHAR *)query1, SQL_NTS);
  5.  
  6. //////////////////////////////
  7.  
But above code is unable to retrive the data from DB.

Can you please give me any suggestions.

where as same query if i run in sql analyzer the values are coming correctly.

Thanks in advance

Venkat
My guess is the SELECT query is being interpreted in the C program. Did you try storing it, and then printing it out - make sure all the proper characters are there?
Mar 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Fatt Shin | last post by:
Hi, I'm running MySQL 4.0.13, connecting from PowerBuilder 9 using ODCB Connector 3.51. I'm facing a problem where whenever I issue a SELECT COUNT(*) statement from PowerBuilder, I always get SQL...
2
by: FizzBin | last post by:
We are writing a C application that is using ODBC to insert records into a database. We have a NOT NULL column that can legitimately have an empty value, i.e. we know the value and it is empty...
7
by: Együd Csaba | last post by:
Hi, I've a problem with some of my stored procs. My config is: RH7.1, Postgres 7.3.2 I had converted a few fields of a few tables from one type to another and after this I made all the...
0
by: Tim Northrup | last post by:
Help! We have DB2 V7.2 (fixpak 12) installed on Windows2003 Server, and the latest V7.2 client installed on another system. The DB2CODEPAGE on all systems is set to 1208, and the database was...
3
by: Victorb17 | last post by:
I am building a windows app, and need to connect to a Microsoft Access Database. How might I go about doing this? I know sql if that helps any. I am using Dev C++ and writing in C
4
by: Dave | last post by:
Hey guys, I have an ODBC problem that has me stumped. I wrote a VBA script to run in Microsoft Excel that pulls data out of an application using that application's ODBC driver and puts it into...
138
by: Ian Boyd | last post by:
i've been thrown into a pit with DB2 and have to start writing things such as tables, indexes, stored procedures, triggers, etc. The online reference is only so helpful. The two pdf manuals are...
3
by: leejwen | last post by:
I'd like to execute this SQL by SQLExecDirect, select * from abc where A = 'ab%'; Could anybody know how? but attention, below is just not working _stprintf((char *)szSqlCommand, "select *...
2
by: mailravid | last post by:
Hi, When I execute SQLExecDirect() in C++, and if my link between server and client is fluctuating, it returns after a long time and my application hangs. why is this happenning can any give...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.