Hi,all
I am using Mysql 5.0 But I get an error message for calling procedure
with mysql_query().
My program is shown below:
Thank & Regard.
Gary.
#define W32_LEAN_AND_MEAN
#include <windows.h>
#include <mysql.h>
#include <stdio.h>
#include <string>
int main(int argc, char** argv)
{
MYSQL* sqlid = mysql_init(0);
if (!mysql_real_connect(sqlid, "localhost", "test", "test", "test", 0,
0, CLIENT_MULTI_STATEMENTS)) {
printf("%s\n", mysql_error(sqlid));
mysql_close(sqlid);
return -1;
}
sqlid->reconnect = 1;
std::string proc = "call pro_ins_department(10, 'test',
'testprocedure')";
if (0 != mysql_query(sqlid, proc.c_str())) {
printf("operator failed:%d %s\n", mysql_errno(sqlid),
mysql_error(sqlid));
} else {
MYSQL_RES * rs = mysql_store_result (sqlid);
MYSQL_ROW row = mysql_fetch_row(rs);
unsigned __int64 id = (unsigned __int64)atoi(row[0]);
printf("get id:id=%d\n", id);
}
mysql_close(sqlid);
return 0;
} 2 5923
Gary li wrote:
Hi,all
I am using Mysql 5.0 But I get an error message for calling procedure
with mysql_query().
My program is shown below:
Thank & Regard.
Gary.
#define W32_LEAN_AND_MEAN
#include <windows.h>
#include <mysql.h>
#include <stdio.h>
#include <string>
int main(int argc, char** argv)
{
MYSQL* sqlid = mysql_init(0);
if (!mysql_real_connect(sqlid, "localhost", "test", "test", "test", 0,
0, CLIENT_MULTI_STATEMENTS)) {
printf("%s\n", mysql_error(sqlid));
mysql_close(sqlid);
return -1;
}
sqlid->reconnect = 1;
std::string proc = "call pro_ins_department(10, 'test',
'testprocedure')";
if (0 != mysql_query(sqlid, proc.c_str())) {
printf("operator failed:%d %s\n", mysql_errno(sqlid),
mysql_error(sqlid));
} else {
MYSQL_RES * rs = mysql_store_result (sqlid);
MYSQL_ROW row = mysql_fetch_row(rs);
unsigned __int64 id = (unsigned __int64)atoi(row[0]);
printf("get id:id=%d\n", id);
}
mysql_close(sqlid);
return 0;
}
you have to make sure that you the username you're using has execute
privileges on that stored procedure in the database you're connecting
to. otherwise, it looks ok to me.
But It's still the same error for using root username.
lark 写道:
Gary li wrote:
Hi,all
I am using Mysql 5.0 But I get an error message for calling procedure
with mysql_query().
My program is shown below:
Thank & Regard.
Gary.
#define W32_LEAN_AND_MEAN
#include <windows.h>
#include <mysql.h>
#include <stdio.h>
#include <string>
int main(int argc, char** argv)
{
MYSQL* sqlid = mysql_init(0);
if (!mysql_real_connect(sqlid, "localhost", "test", "test", "test", 0,
0, CLIENT_MULTI_STATEMENTS)) {
printf("%s\n", mysql_error(sqlid));
mysql_close(sqlid);
return -1;
}
sqlid->reconnect = 1;
std::string proc = "call pro_ins_department(10, 'test',
'testprocedure')";
if (0 != mysql_query(sqlid, proc.c_str())) {
printf("operator failed:%d %s\n", mysql_errno(sqlid),
mysql_error(sqlid));
} else {
MYSQL_RES * rs = mysql_store_result (sqlid);
MYSQL_ROW row = mysql_fetch_row(rs);
unsigned __int64 id = (unsigned __int64)atoi(row[0]);
printf("get id:id=%d\n", id);
}
mysql_close(sqlid);
return 0;
}
you have to make sure that you the username you're using has execute
privileges on that stored procedure in the database you're connecting
to. otherwise, it looks ok to me.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Robin Tucker |
last post by:
Hi,
I have one stored procedure that calls another ( EXEC proc_abcd ). I would
like to return a result set (a temporary table I have created in the
procedure proc_abcd) to the calling procedure...
|
by: adolf garlic |
last post by:
Im trying to return xml from sql.
The xml is made up of different fragments, some using FOR XML ... syntax.
The result is a valid xml doc.
There is a working stored proc that returns the xml
In...
|
by: Raquel |
last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it
seems to run fine but returns NOTHING. I mean..as if nothing has
happened..not resultset is returned. I am passing value...
|
by: Stanley Sinclair |
last post by:
I have a need to return multiple result sets from a stored procedure.
Want that SP to call others to get the data.
Win2003, db2 8.1.5.
Can't figure out how to handle open cursors, and return...
|
by: Randy Foster |
last post by:
We have a stored procedure (on DB2 8.1 FP5) that returns multiple
result sets which we are calling from Java (WebSphere 5.0.2.8).
We can call the stored procedure from the DB2 command line...
| |
by: db2sysc |
last post by:
All:
I am writing a MAIN CALLING PROCEDURE. This call lot of procedures.
Some of the CALLED PROCEDURES end with an OPEN C1 (cursor). How to I
read this open cursor in my main procedure?? In java...
|
by: Tim Marshall |
last post by:
Here's the scenario, A2003, Jet back end, illustrated with some cut down
code at the end of the post:
A proc dims a snapshot recordset (dim rst as Dao.recordset) and opens
it. There are several...
|
by: orencs |
last post by:
Hi,
I am using Datareader and stored procedure in C# ADO.NET.
When I am running the stored procedure in the SQL Query Analyzer and
recieve two rows (as I hace expected)
col1 col2
0 1
0 ...
|
by: David Greenberg |
last post by:
Hello
I'm calling a stored procedure in VB6 using the "execute" command of
rdoquery.
Does anyone know how to check whether or not the execute command was
succesfull or not. Not on the level of...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |