473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Example not working/incorrect

I am trying to determine the field names using the C API using the
example from mysql manual
(http://dev.mysql.com/doc/mysql/en/my...-fields.html):

MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)

Description

Returns an array of all MYSQL_FIELD structures for a result set. Each
structure provides the field definition for one column of the result set.

Return Values

An array of MYSQL_FIELD structures for all columns of a result set.

Errors

None.

Example

unsigned int num_fields;
unsigned int i;
MYSQL_FIELD *fields;

num_fields = mysql_num_fields(result);
fields = mysql_fetch_fields(result);
for(i = 0; i < num_fields; i++)
{
printf("Field %u is %s\n", i, fields[i].name);
}

The manual says that the function returns an array. I ran a query which
returns data in six columns so to my opinion the valid indexes should be
0 upto and including 5. The definition of the variables does not
indicate an array being declared for fields to my opinion. It seems to
ve more like a field definition to me.

The first time I run thel loop (i=0) everything works perfectly, but
when I run the loop for the second time (i=1) the system crashes with an
access violation.

I added a watch to see whether the result was really an array and it
does *not* seem to be an array. Can someone tell me if I do something
wrong or if there could be a bug in the C API functions.

System:
Microsoft Visual C++ 6
Mysql 4.1.11-nt

Thanks in advance!

Jonathan

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #1
1 1240
Jonathan wrote:
I am trying to determine the field names using the C API using the
example from mysql manual
(http://dev.mysql.com/doc/mysql/en/my...-fields.html):

MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)

Description

Returns an array of all MYSQL_FIELD structures for a result set. Each
structure provides the field definition for one column of the result set.

Return Values

An array of MYSQL_FIELD structures for all columns of a result set.

Errors

None.

Example

unsigned int num_fields;
unsigned int i;
MYSQL_FIELD *fields;

num_fields = mysql_num_fields(result);
fields = mysql_fetch_fields(result);
for(i = 0; i < num_fields; i++)
{
printf("Field %u is %s\n", i, fields[i].name);
}

The manual says that the function returns an array. I ran a query which
returns data in six columns so to my opinion the valid indexes should be
0 upto and including 5. The definition of the variables does not
indicate an array being declared for fields to my opinion. It seems to
ve more like a field definition to me.

The first time I run thel loop (i=0) everything works perfectly, but
when I run the loop for the second time (i=1) the system crashes with an
access violation.

I added a watch to see whether the result was really an array and it
does *not* seem to be an array. Can someone tell me if I do something
wrong or if there could be a bug in the C API functions.

System:
Microsoft Visual C++ 6
Mysql 4.1.11-nt

Thanks in advance!

Jonathan


I resolved the problem with the use of the MYSQL support team!

It turnde out to be the program using an older version of the
libmysql.dll in the windows\system32 directory instead of the linked
library I explicitly specified.

Jonathan

http://bugs.mysql.com/bug.php?id=10645

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: thilbert | last post by:
All, I have a perplexing problem that I hope someone can help me with. I have the following table struct: Permission ----------------- PermissionId Permission
23
by: Alberto | last post by:
An OUTSTANDING example of a rebuttal. Worth a glance. Rather long, OBVIOUSLY feel fee to dismiss it entirely if not interested. But this habit of the rebuttals must go to a stop (forgive odd...
11
by: ajikoe | last post by:
Hello, I used Visual C# Standard Edition. I want to comment my program using xml commentary method, I don't know why if I use value and example tag, it is not working / showed in the html...
4
by: David | last post by:
Hi, I have taken some SQL from MS Access and got it working. I have since updated the SQL in Access but cannot get the additional part working in ASP. The working SQL I have in asp is:- ...
1
by: tshad | last post by:
I have a site with SSL connected and in my IIS 6 properties window the port is set to 4434 and it was working OK. I then accidently put 4434 in another site on a machine and it quit working. I...
318
by: jacob navia | last post by:
Rcently I posted code in this group, to help a user that asked to know how he could find out the size of a block allocated with malloc. As always when I post something, the same group of people...
3
by: Ron Jackson | last post by:
I am using Python 2.5 on Windows XP. I have installed Pyserial and win32all extensions. When I try to run the example program scan.py (included below), or any other program using pyserial, as...
31
by: ajos | last post by:
hi frnds, i have a form,which has 2 input text boxes, the values are entering the text boxes,when i leave the 2 text boxes blank and hit submit a java script gives the message that the 2 fields are...
7
by: raylopez99 | last post by:
On Aug 16, 3:49 pm, Marc Gravell <marc.grav...@gmail.comwrote: If you cannot understand such a simple post, then you don't understand generic delegate types. Apparently you can only read your...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
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 project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.